Google 跟踪代码管理器

本页相关主题

  • 使用 Google Tag Manager 的注意事项

  • 将 Google 跟踪代码管理器代码添加到您的模板中

  • 验证是否已安装 Google 跟踪代码管理器

  • 相关链接

使用 Google Tag Manager 的注意事项

若要对 Shopify Plus 的在线商店使用 Google Tag Manager,请执行以下操作:

  • 拥有 checkout.liquid 文件的访问权限。如果您无权在模板代码中访问此文件,请联系 Shopify Plus 支持获取访问权限。

  • 将 Shopify 的集成用于 Google Analytics 和 Facebook Pixel,而不是将其用于 Google 跟踪代码管理器。

  • 将 Google Tag Manager 提供的代码片段复制到您的 theme.liquid 和 checkout.liquid 模板文件中。

将 Google 跟踪代码管理器代码添加到您的模板中

步骤:

  1. 安装 Google 跟踪代码管理器 以获取您需要复制并粘贴到 Shopify 商店中的代码片段。由于 Shopify 使用模板,因此您只需将代码片段复制到 theme.liquid 和 checkout.liquid 文件。

    • 如果这是您首次安装 Google 跟踪代码管理器,请使用 Google 跟踪代码管理器提供的安装步骤。在您获得要向网页添加的两个代码片段的步骤时暂停,然后按照以下说明操作。

    • 如果您已安装 Google 跟踪代码管理器,则可通过依次点击后台安装 Google 跟踪代码管理器,在 Google 跟踪代码管理器中找到这些代码片段。

  2. 在 Shopify 后台,点击在线商店,然后点击模板

  3. 在模板下拉菜单中,点击编辑代码

  4. 将 Google Tag Manager 中的第一个代码片段复制到您的 theme.liquid 和 checkout.liquid 代码的 <head> 标记中:

    1. 复制 Google 跟踪代码管理器中的第一个代码片段

    2. 在您的 Shopify 后台中,打开 theme.liquid 文件。

    3. 将代码片段粘贴到 theme.liquid 代码的 <head> 中尽可能高的位置。

    4. 打开您的 checkout.liquid 文件。

    5. 将代码片段粘贴到 checkout.liquid 代码的 <head> 中尽可能高的位置。

  5. 将 Google 跟踪代码管理器中的第二个代码片段复制到您的 theme.liquid 和 checkout.liquid 代码的 <body> 标签:

    1. 在您的 Shopify 后台,打开 theme.liquid 页面。

    2. 将代码片段粘贴到 theme.liquid 页面的 <body> 中尽可能靠前的位置。

    3. 打开 checkout.liquid 页面。

    4. 将代码片段粘贴到 checkout.liquid 代码的 <body> 中尽可能高的位置。

  6. 在 Shopify 后台,点击保存

  7. 在 Google Tag Manager 中,继续安装 Google Tag Manager。当系统提示您添加标记时,请勿添加以下类型的标记:

    • 适用于 Google Analytics 的 Universal Analytics

    • 适用于 Google Analytics 的 Classic Google Analytics

    • Facebook Pixel。

验证是否已安装 Google 跟踪代码管理器

要验证您是否已正确安装 Google 跟踪代码管理器,您可以使用:

  • Google 跟踪代码管理器中的预览模式

  • Google Tag Assistant Chrome 扩展。

相关链接

  • theme.liquid

  • checkout.liquid

  • Google 跟踪代码管理器文档

  • 在 Shopify 中使用 Google Analytics

  • 在 Shopify 中使用 Facebook Pixel

Shopify商户官网原文详情:

Google Tag Manager

On this page

  • Considerations for using Google Tag Manager

  • Add Google Tag Manager code to your theme

  • Verify that Google Tag Manager is installed

  • Related links

Considerations for using Google Tag Manager

To use Google Tag Manager with your Shopify Plus online store, you do the following:

  • Have access to the checkout.liquid file. If you don't have access to this file in your theme code, then contact Shopify Plus Support to gain access.

  • Use Shopify's integration for Google Analytics and Facebook Pixel instead of using them with Google Tag Manager.

  • Copy the code snippets that are provided by Google Tag Manager into your theme.liquid and checkout.liquid theme files.

Add Google Tag Manager code to your theme

Steps:

  1. Install Google Tag Manager to get the code snippets that you will need to copy and paste into your Shopify store. Because Shopify uses templates, you only need to copy the snippets into the theme.liquid and checkout.liquid files.

    • If this is your first time installing Google Tag Manager, then use the installation steps provided by Google Tag Manager. Pause at the step where you are given two code snippets to add to your web pages, and then follow the instructions below.

    • If you have already installed Google Tag Manager, then you can find these code snippets in your Google Tag Manager by clicking Admin, and then clicking Install Google Tag Manager.

  2. In your Shopify admin, click Online store, and then click Themes.

  3. In the theme drop-down, click Edit Code.

  4. Copy the first code snippet from Google Tag Manager into the <head> tags of your theme.liquid and checkout.liquid code:

    1. Copy the first code snippet from Google Tag Manager

    2. In your Shopify admin, open your theme.liquid file.

    3. Paste the code snippet as high in the <head> of the theme.liquid code as possible.

    4. Open your checkout.liquid file.

    5. Paste the code snippet as high in the <head> of the checkout.liquid code as possible.

  5. Copy the second code snippet from the Google Tag Manager into the <body> tags of your theme.liquid and checkout.liquid code:

    1. In your Shopify admin, open the theme.liquid page.

    2. Paste the code snippet as high in the <body> of the theme.liquid page as possible.

    3. Open the checkout.liquid page.

    4. Paste the code snippet as high in the <body> of the checkout.liquid code as possible.

  6. In your Shopify admin, click Save.

  7. In Google Tag Manager, continue installing the Google Tag Manager. When prompted to add tags, do not add the following types of tags:

    • Universal Analytics for Google Analytics

    • Classic Google Analytics for Google Analytics

    • Facebook Pixel.

Verify that Google Tag Manager is installed

To verify that you installed Google Tag Manager properly, you can use:

  • the Preview Mode in Google Tag Manager

  • the Google Tag Assistant Chrome Extension.

Related links

  • theme.liquid

  • checkout.liquid

  • Google Tag Manager documentation

  • Working with Google Analytics in Shopify

  • Using Facebook Pixel in Shopify


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

(本文内容根据网络资料整理,出于传递更多信息之目的,不代表连连国际赞同其观点和立场)