本文是一个简单的分步指南,将介绍如何将Google Ads再营销代码添加到Shopify。
步骤一(获取你的受众源Tag ID)
登录Adwords,点击右上角菜单,在共享库中选择受众群体管理器
点击受众群体来源
然后点击修改来源
按照以下内容设置:
- 动态再营销
- 收集用户在您网站上执行的特定操作的数据,以展示个性化广告。
- 业务类型
- 零售
单击自行添加代码
然后选择新版。复制受众源Tag ID, 后面会使用到该ID。
步骤二(将跟踪代码添加到模板theme.liquid)
登陆shopify后台,选择Online Store > Themes
单击编辑代码
打开theme.liquid
在下面的代码中,除了可供修改的几个地方外,请勿更改其他内容,否则功能将失效。可供修改的地方如下图黄色背景文字。
- 将以下代码复制到文本编辑器中,并将fa_google_ads_audience_tag_id的值替换为你的受众源Tag ID
- 如果你想定位到其他国家,请将fa_product_id_alpha2_code的值修改为目标国家。例如,英国是GB。
- 如果你在美国,则需要设置fa_prices_with_decimal_separator为true.如果在欧洲,则将其改为false。
- 打开Merchant Center,查看产品>产品列表>ID列
- 如果ID类似于shopify_US_81191654332_1055121650148,则将fa_product_id设置为default
- 如果ID类似于1055121650148,则将值fa_product_id设置为product_id
- 如果ID是网站SKU,则将值fa_product_id设置为sku
修改完以上几项后,将其粘贴到theme.liquid文件<head></head>中
<!-- Google Ads Remarketing Tag By Shopify_Fans --> <!-- 替换掉受众源Tag ID-- --> {% assign fa_google_ads_audience_tag_id = 123456789 %} <!-- 根据国家修改国家代码 --> {% assign fa_product_id_alpha2_code = 'US' %} {% assign fa_prices_with_decimal_separator = true %} <!-- 根据上文步骤4, 修改product_id(default / product_id / sku) --> {% assign fa_product_id = 'default' %} <!-- ------------------------------------ --> <!-- 请勿修改以下内容 --> <!-- Global site tag (gtag.js) - Ads. --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-{{ fa_google_ads_audience_tag_id }}"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-{{ fa_google_ads_audience_tag_id }}'); </script> <!-- Global site tag (gtag.js) - Ads. --> {% if fa_prices_with_decimal_separator == true %} {% if template contains 'product' %} {% assign fa_product_price = product.price_min | money_without_currency | remove:',' %} {% elsif template contains 'cart' %} {% assign fa_product_price = cart.total_price | money_without_currency | remove:',' %} {% endif %} {% else %} {% if template contains 'product' %} {% assign fa_product_price = product.price_min | money_without_currency | remove:'.' | replace: ',', '.' %} {% elsif template contains 'cart' %} {% assign fa_product_price = cart.total_price | money_without_currency | remove:'.' | replace: ',', '.' %} {% endif %} {% endif %} {% if template contains 'collection' %} {% assign fa_event = 'view_item_list' %} {% elsif template contains 'product' %} {% assign fa_event = 'view_item' %} {% elsif template contains 'search' %} {% assign fa_event = 'view_search_results' %} {% elsif template contains 'cart' %} {% assign fa_event = 'add_to_cart' %} {% elsif template contains 'index' %} {% assign fa_event = 'home' %} {% else %} {% assign fa_event = 'other' %} {% endif %} <script> gtag('event', '{{ fa_event }}', { 'send_to': 'AW-{{ fa_google_ads_audience_tag_id }}', {% if template contains 'product' or template contains 'cart' %}'value': {{ fa_product_price }},{% endif %} {% if template contains 'product' %} 'items': [{ {% if fa_product_id == 'default' %} 'id': 'shopify_{{ fa_product_id_alpha2_code }}_{{ product.id }}_{% if product.variants.first.id %}{{ product.variants.first.id }}{% else %}{{ product.variants.id }}{% endif %}', {% elsif fa_product_id == 'product_id' %} 'id': '{% if product.variants.first.id %}{{ product.variants.first.id }}{% else %}{{ product.variants.id }}{% endif %}', {% elsif fa_product_id == 'parent_id' %} 'id': '{{ product.id }}', {% elsif fa_product_id == 'sku' %} 'id': '{% if product.variants.first.id %}{{ product.variants.first.sku }}{% else %}{{ product.variants.sku }}{% endif %}', {% endif %} 'google_business_vertical': 'retail' }] {% elsif template contains 'cart' %} 'items': [ {% for item in cart.items %} { {% if fa_product_id == 'default' %} 'id': 'shopify_{{ fa_product_id_alpha2_code }}_{{ item.product_id }}_{{ item.variant_id }}', {% elsif fa_product_id == 'product_id' %} 'id': '{{ item.variant_id }}', {% elsif fa_product_id == 'parent_id' %} 'id': '{{ item.product_id }}', {% elsif fa_product_id == 'sku' %} 'id': '{{ item.sku }}', {% endif %} 'google_business_vertical': 'retail' }, {% endfor %} ] {% endif %} }); </script> <!-- Google Ads Remarketing Tag By Shopify_Fans END -->
转到Settings > Checkout
向下滚动,找到 Additional scripts
在下面的代码中,除了可供修改的几个地方外,请勿更改其他内容,否则功能将失效。可供修改的地方如下图黄色背景文字。
- 将以下代码复制到文本编辑器中,并将fa_google_ads_audience_tag_id的值替换为你的受众源Tag ID
- 如果你想定位到其他国家,请将fa_product_id_alpha2_code的值修改为目标国家。例如,英国式GB。
- 如果你在美国,则需要设置fa_prices_with_decimal_separator为true.如果在欧洲,则将其改为false。
- 打开Merchant Center,查看产品>产品列表>ID列
- 如果ID类似于shopify_US_81191654332_1055121650148,则将fa_product_id设置为default
- 如果ID类似于1055121650148,则将值fa_product_id设置为product_id
- 如果ID是网站SKU,则将值fa_product_id设置为sku
修改完以上几项之后,将其粘贴到Additional scripts中并保存。
<!-- Google Ads Remarketing Tag By Shopify_Fans -->
<!-- 替换掉受众源Tag ID -->
{% assign fa_google_ads_audience_tag_id = 123456789 %}
<!-- 根据国家修改国家代码 -->
{% assign fa_product_id_alpha2_code = 'US' %}
{% assign fa_prices_with_decimal_separator = true %}
<!-- 根据上文步骤4, 修改product_id(default / product_id / sku) -->
{% assign fa_product_id = 'default' %}
<!-- ------------------------------------ -->
<!-- 请勿修改以下内容 -->
<!-- Global site tag (gtag.js) - Ads. -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-{{ fa_google_ads_audience_tag_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-{{ fa_google_ads_audience_tag_id }}');
</script>
<!-- Global site tag (gtag.js) - Ads. -->
{% if fa_prices_with_decimal_separator == true %}
{% assign fa_product_price = checkout.total_price | money_without_currency | remove:',' %}
{% else %}
{% assign fa_product_price = checkout.total_price | money_without_currency | remove:'.' | replace: ',', '.' %}
{% endif %}
{% assign fa_event = 'purchase' %}
<script>
gtag('event', '{{ fa_event }}', {
'send_to': 'AW-{{ fa_google_ads_audience_tag_id }}',
'value': {{ fa_product_price }},
'items': [
{% for item in checkout.line_items %}
{
{% if fa_product_id == 'default' %}
'id': 'shopify_{{ fa_product_id_alpha2_code }}_{{ item.product_id }}_{{ item.variant_id }}',
{% elsif fa_product_id == 'product_id' %}
'id': '{{ item.variant_id }}',
{% elsif fa_product_id == 'parent_id' %}
'id': '{{ item.parent_id }}',
{% elsif fa_product_id == 'sku' %}
'id': '{{ item.sku }}',
{% endif %}
'google_business_vertical': 'retail'
},
{% endfor %}
]
});
</script>
<!-- Google Ads Remarketing Tag By Shopify_Fans END -->
检查是否安装成功
登陆Adwords > 工具与设置 > 共享库 > 受众群体管理器 > 受众群体来源。
若命中次数有增加,则表示安装成功。
评论