设置 Google Analytics

要想开始收集有关您商店的数据,您需要拥有 Google 账号、注册分析跟踪以及选择您要跟踪的数据。

本页相关主题

  • 步骤 1:确保您尚未启用 Google Analytics

  • 步骤 2:获取 Google 账号

  • 步骤 3:启用 Google Analytics

  • 步骤 4:开启电子商务跟踪

  • 其他 Google Analytics JavaScript

步骤 1:确保您尚未启用 Google Analytics

多次启用 Google Analytics 会导致数据不准确。如果您确定之前从未为商店启用过 Google Analytics,请跳至步骤 2:获取 Google 账号。如果您不确定之前是否为商店启用过 Google Analytics,请按以下步骤进行操作:

  1. 在 Shopify 后台中,转到在线商店 > 偏好设置

  2. 在 Google Analytics 部分中,请确保该框中只有在此处粘贴来自 Google 的代码字样或者为空。如果您看到此内容,请继续执行下一步。如果您看到以 UA- 开头的代码,则代表您已经启用了 Google Analytics,可以跳到步骤 4:开启电子商务跟踪。

  3. 点击模板

  4. 点击操作 > 编辑代码

  5. 布局部分中,点击 {/} theme.liquid

  6. 在 theme.liquid 文件中,查找下列任何 Google Analytics 跟踪代码:ga.jsdc.jsgtag.js 或 analytics.js。如果您在 theme.liquid 文件中看到任何这些标签,则代表您已经启用了 Google Analytics,可以跳到步骤 4:开启电子商务跟踪。

如果您在偏好设置页面的 Google Analytics 部分中未看到跟踪代码,并且您的 theme.liquid 文件中没有 Google Analytics 跟踪标签,则您的商店未启用 Google Analytics。请继续执行步骤 2:获取 Google 账号。

步骤 2:获取 Google 账号

您需要 Google 账号才能使用 Google Analytics。如果您已使用 Google 产品,例如 Gmail 或 Ads,则可以为 Google Analytics 使用相同的账户。

如果您还没有用于 Google 产品的账户,请创建一个 Google 账号。除了登录和退出 Google Analytics 之外,您不需要使用 Gmail 账户执行任何操作。

在您拥有 Google 账户后,您需要创建一个 Analytics 账户。创建账户后,请继续执行步骤 3:启用 Google Analytics。

步骤 3:启用 Google Analytics

若要启用 Google Analytics,您必须在 Google 中创建 Universal Analytics 属性,并将其添加到您的 Shopify 商店中。

步骤:

  1. 在 Web 浏览器中,登录 Google Analytics。

  2. 点击后台

  3. 账户列中,选择正确的账户。

  4. 属性列中,点击创建属性

  5. 输入属性的名称。

  6. 选择仅创建 Universal Analytics 属性

  1. 点击下一步

  2. 选择相应的设置。

  3. 点击创建

  4. 通过突出显示 Universal Analytics 属性并按下 ctrl+C (PC) 或 command+C (Mac) 将其复制到剪贴板。

  5. 在新的浏览器标签中,打开 Shopify 后台。

  6. 转到在线商店 > 偏好设置

  7. 在 Google Analytics 部分中,将您的 Universal Analytics 属性粘贴到 Google Analytics 账户字段中。

在对您的商店启用了 Google Analytics 后,请继续进行步骤 4:开启电子商务跟踪。

步骤 4:开启电子商务跟踪

您可以通过两种不同程度的详细信息来实现 Google 的电子商务跟踪:

  • 如果您只想获取交易和收入数据,则可以使用基础的电子商务跟踪

  • 如果您想了解有关访客行为的其他信息,请使用增强型电子商务跟踪

开启基础的电子商务跟踪

步骤:

  1. 在您的 Google Analytics 账户中,点击后台

  2. 视图列中,点击电子商务设置

  3. 点击启用电子商务切换按钮,将它从切换为

如果您需要更详细的跟踪信息,则可以开启增强型电子商务跟踪功能。

开启增强型电子商务跟踪

步骤:

  1. 在 Shopify 后台中,转到在线商店 > 偏好设置

  2. 在 Google Analytics 部分中,选中使用增强型电子商务。如果您使用的是旧版 Google Analytics,则可能需要先点击升级到最新版本,然后才能点击使用增强型电子商务复选框。

  3. 点击保存。这样就会使 Shopify 能够跟踪您所有的网站数据并将这些数据发送到 Google Analytics。

  4. 在您的 Google Analytics 账户中,点击后台

  5. 视图列中,点击电子商务设置

  6. 点击启用增强型电子商务报告切换按钮,将它从切换为

  7. 点击保存

在 Google Analytics 帮助中心了解有关增强型电子商务的详细信息。

其他 Google Analytics JavaScript

如果您需要进一步自定义 Google Analytics 设置,可将 Javascript 代码添加到其他 Google Analytics Javascript 部分

这部分只接受与分析跟踪相关的 Javascript。此字段中添加的代码无法对结账进行直观的或功能方面的更改。

详细了解如何将 JavaScript 用于 Google Analytics。

Shopify商户官网原文详情:

Setting up Google Analytics

Before you can start gathering data about your store, you need to have a Google account, sign up for analytics tracking, and choose what data you want to track.

On this page

  • Step 1: Make sure you don't have Google Analytics enabled already

  • Step 2: Create a Google Account

  • Step 3: Enable Google Analytics

  • Step 4: Turn on ecommerce tracking

  • Additional Google Analytics JavaScript

Step 1: Make sure you don't have Google Analytics enabled already

Enabling Google Analytics more than once results in inaccurate data. If you're sure you've never enabled Google Analytics for your store before, then skip to Step 2: Get a Google Account. If you aren't sure whether you've enabled Google Analytics for your store before, then follow these steps:

  1. From your Shopify admin, go to Online store > Preferences.

  2. In the Google Analytics section, make sure that the box has only the text Paste your code from Google here, and is otherwise empty. If you see this, then continue to the next step. If you see a code beginning with UA- instead, then you have Google Analytics enabled already and can skip to Step 4: Turn on ecommerce tracking.

  3. Click Themes.

  4. Click Actions > Edit code.

  5. In the Layout section, click {/} theme.liquid.

  6. In the theme.liquid file, look for any of the following Google Analytics tracking tags: ga.jsdc.jsgtag.js, or analytics.js. If you see any of these tags in your theme.liquid file, then you have Google Analytics enabled already and can skip to Step 4: Turn on ecommerce tracking.

If you don't see a tracking code in the Google Analytics section of your Preferences page, and you don't have a Google Analytics tracking tag in your theme.liquid file, then Google Analytics isn't enabled on your store. Continue to Step 2: Get a Google Account.

Step 2: Create a Google Account

You need a Google account to use Google Analytics. If you already use Google products, such as Gmail or Ads, then you can use the same account for Google Analytics.

If you don't already have an account for a Google product, then create a Google account. You don't have to use the Gmail account for anything other than signing in and out of Google Analytics.

After you have a Google account, you need to Create an Analytics account. After you create your account, continue to Step 3: Enable Google Analytics.

Step 3: Enable Google Analytics

To enable Google Analytics, you must create a Universal Analytics property in Google and add it to your Shopify store.

Steps:

  1. In a web browser, sign in to Google Analytics.

  2. Click Admin.

  3. In the Account column, select the correct account.

  4. In the Property column, click Create Property.

  5. Enter a name for the property.

  6. Select Create a Universal Analytics property only.

  1. Click Next.

  2. Select the appropriate settings.

  3. Click Create.

  4. Copy the Universal Analytics property to your clipboard by highlighting it and pressing ctrl+C on PC or command+C on Mac.

  5. In a new browser tab, open your Shopify admin.

  6. Go to Online store > Preferences.

  7. In the Google Analytics section, paste your Universal Analytics property in the Google Analytics account field.



After you enable Google Analytics on your store, continue to Step 4: Turn on ecommerce tracking.

Step 4: Turn on ecommerce tracking

You can implement Google's ecommerce tracking at two different degrees of detail:

  • Basic ecommerce tracking if you just want transaction and revenue data

  • Enhanced ecommerce tracking if you want additional information about visitor behavior

Turn on basic ecommerce tracking

Steps:

  1. In your Google Analytics account, click Admin.

  2. In the View column, click Ecommerce Settings.

  3. Click the Enable Ecommerce toggle to turn it from OFF to ON.

If you need more detailed tracking information, then you can turn on Enhanced Ecommerce tracking.

Turn on enhanced ecommerce tracking

Steps:

  1. From your Shopify admin, go to Online store > Preferences.

  2. In the Google Analytics section, check Use Enhanced Ecommerce. If you're using an older version of Google Analytics, then you might need to click Upgrade to the latest version before you can click the Use Enhanced Ecommerce checkbox.

  3. Click Save. This enables Shopify to track and send all of your website data to Google Analytics.

  4. In your Google Analytics account, click Admin.

  5. In the View column, click Ecommerce Settings.

  6. Click the Enable Enhanced Ecommerce Reporting toggle to turn it from OFF to ON.

  7. Click Save.

Learn more about Enhanced Ecommerce from Google Analytics Help.

Additional Google Analytics JavaScript

If you want to further customize your Google Analytics setup, then you can add Javascript code to the Additional Google Analytics Javascript section.

This section only accepts Javascript related to analytics tracking. Code added in this field can't make visual or functional changes to your checkout.

Learn more about using JavaScript for Google Analytics.


文章内容来源:Shopify商户官方网站