FeedArmy Co., Ltd.

How To Add Google Ads Remarketing Tag To Shopify

An easy step by step guide on how to add Google Ads remarketing tag to Shopify using the latest features.

Step 1) Get Your Audience Source Tag ID

Login to Google Ads, then in the left hand menu select Tools > Audience manager

Google Ads Audience Manager

From the top menu, click on Your data sources

Here you will see all your panels, click on the 3dot menu for Google Ads Tag and select edit source. Or if that is not available click on set up tag.

Or go to this URL: https://ads.google.com/aw/audiences/management/datasources/tagsetup

Select the following:

Click on Install the tag yourself

Copy the numeric source tag id as shown in the image below for later use. We will add the source tag id to the script below.

Step 2) Adding The Tracking Code To theme.liquid

Click on theme.liquid inside the layout folder

From the code example below, edit the value between code settings start and end. Do not change anything else or you might break the functionality. I have highlighted below what you can edit.

  1. Copy the below code into a text editor and replace the fa_google_ads_audience_tag_id value to your audience tag id
  2. By default the code is set up for the US, if you targeting a different country, change the value of fa_product_id_alpha2_code to your target country alpha2. For example, the United Kingdom is GB. You can find the full list here: https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference/enum/countrycode
  3. The following step requires you to check the product id in Google Merchant Center > Products > List. And see what ID you are using.
    1. If it looks like shopify_US_81191654332_1055121650148, then keep fa_product_id set to default
    2. If it looks like 1055121650148 then set the value fa_product_id to product_id
    3. If it looks like the main id 81191654332 then set the value fa_product_id to parent_id
    4. If it looks like a sku then set the value fa_product_id to sku

When you have updated the code settings, paste it in the theme.liqued file between the opening and closing head tag. <head></head>

<!-- Google Ads Remarketing Tag By FeedArmy Version 2.17 START -->
<!-- FeedArmy tutorial found at https://feedarmy.com/kb/adding-google-adwords-remarketing-tag-to-shopify/ -->

<!-- CODE SETTINGS START -->
<!-- CODE SETTINGS START -->

<!-- Please add your Google Ads Audience Source Tag ID -->
{% assign fa_google_ads_audience_tag_id = 123456789 %}

<!-- Please add your alpha2 code, you can find it here: https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference/enum/countrycode -->
{% assign fa_product_id_alpha2_code = 'US' %}

<!-- set your product id values are default, product_id, parent_id, sku-->
{% assign fa_product_id = 'default' %}

<!-- CODE SETTINGS END -->
<!-- CODE SETTINGS END -->

<!-- ==================================== -->
<!-- DO NOT EDIT ANYTHING BELOW THIS LINE -->
{% if fa_google_coding %}{% assign fa_google_coding = true %}{%- else -%}{% assign fa_google_coding = false %}{%- endif -%}
{% if fa_google_coding == false %}
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-{{ fa_google_ads_audience_tag_id }}"></script>
{%- endif -%}
{%- assign fa_current_variant = product.selected_or_first_available_variant -%}
{%- if cart.currency.iso_code == 'GBP' or cart.currency.iso_code == 'USD' or cart.currency.iso_code == 'CAD' or cart.currency.iso_code == 'AUD' or cart.currency.iso_code == 'BWP' or cart.currency.iso_code == 'BND' or cart.currency.iso_code == 'DOP' or cart.currency.iso_code == 'GTQ' or cart.currency.iso_code == 'HKD' or cart.currency.iso_code == 'INR' or cart.currency.iso_code == 'ILS' or cart.currency.iso_code == 'YEN' or cart.currency.iso_code == 'KES' or cart.currency.iso_code == 'KOR' or cart.currency.iso_code == 'LBP' or cart.currency.iso_code == 'MYR' or cart.currency.iso_code == 'MXN' or cart.currency.iso_code == 'NPR' or cart.currency.iso_code == 'NZD' or cart.currency.iso_code == 'NIO' or cart.currency.iso_code == 'NGN' or cart.currency.iso_code == 'PKR' or cart.currency.iso_code == 'CNY' or cart.currency.iso_code == 'PHP' or cart.currency.iso_code == 'SGD' or cart.currency.iso_code == 'LKR' or cart.currency.iso_code == 'CHF' or cart.currency.iso_code == 'TWD' or cart.currency.iso_code == 'TSH' or cart.currency.iso_code == 'THB' or cart.currency.iso_code == 'UGX' or cart.currency.iso_code == 'KWD' -%}
{% if template contains 'product' %}
{%- assign fa_product_price = fa_current_variant.price | 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 = fa_current_variant.price | money_without_currency | remove:'.' | replace: ',', '.' -%}
{% elsif template contains 'cart' %}
{%- assign fa_product_price = cart.total_price | money_without_currency | remove:'.' | replace: ',', '.' -%}
{% endif %}
{%- endif -%}

{%- if fa_product_id == 'default' -%}
{%- capture fa_product_id_value -%}shopify_{{ fa_product_id_alpha2_code }}_{{ product.id }}_{{ fa_current_variant.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'product_id' -%}
{%- capture fa_product_id_value -%}{{ fa_current_variant.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'parent_id' -%}
{%- capture fa_product_id_value -%}{{product.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'sku' -%}
{%- capture fa_product_id_value -%}{{ fa_current_variant.sku }}{%- endcapture -%}
{%- endif -%}


<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-{{ fa_google_ads_audience_tag_id }}');
</script>

{% 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': [{
			'id': '{{fa_product_id_value}}',
      '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 FeedArmy Version 2.17 END -->

Now go to Settings > Checkout

Scroll down till you see Order Processing > Additional scripts

From the code example below, edit the value between code settings start and end. Do not change anything else or you might break the functionality. I have highlighted below what you can edit.

  1. Copy the below code into a text editor and replace the fa_google_ads_audience_tag_id value to your audience tag id
  2. By default the code is set up for the US, if you targeting a different country, change the value of fa_product_id_alpha2_code to your target country alpha2. For example, the United Kingdom is GB. You can find the full list here: https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference/enum/countrycode
  3. The following step requires you to check the product id in Google Merchant Center > Products > List. And see what ID you are using.
    1. If it looks like shopify_US_81191654332_1055121650148, then keep fa_product_id set to default
    2. If it looks like 1055121650148 then set the value fa_product_id to product_id
    3. If it looks like the main id 81191654332 then set the value fa_product_id to parent_id
    4. If it looks like a sku then set the value fa_product_id to sku

When you completed the code paste it in the additional scripts settings and save.

<!-- Google Ads Remarketing Tag By FeedArmy 2021 Version 2.17 START -->
<!-- FeedArmy tutorial found at https://feedarmy.com/kb/adding-google-adwords-remarketing-tag-to-shopify/ -->

<!-- CODE SETTINGS START -->
<!-- CODE SETTINGS START -->

<!-- Please add your Google Ads Audience Source Tag ID -->
{% assign fa_google_ads_audience_tag_id = 123456789 %}

<!-- Please add your alpha2 code, you can find it here: https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference/enum/countrycode -->
{% assign fa_product_id_alpha2_code = 'US' %}

<!-- set your product id values are default, product_id, parent_id, sku-->
{% assign fa_product_id = 'default' %}

<!-- CODE SETTINGS END -->
<!-- CODE SETTINGS END -->

<!-- ==================================== -->
<!-- DO NOT EDIT ANYTHING BELOW THIS LINE -->
{% if fa_google_coding %}{% assign fa_google_coding = true %}{%- else -%}{% assign fa_google_coding = false %}{%- endif -%}
{% if fa_google_coding == false %}
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-{{ fa_google_ads_audience_tag_id }}"></script>
{%- endif -%}
{%- assign fa_current_variant = product.selected_or_first_available_variant -%}
{%- if checkout.currency == 'GBP' or checkout.currency == 'USD' or checkout.currency == 'CAD' or checkout.currency == 'AUD' or checkout.currency == 'BWP' or checkout.currency == 'BND' or checkout.currency == 'DOP' or checkout.currency == 'GTQ' or checkout.currency == 'HKD' or checkout.currency == 'INR' or checkout.currency == 'ILS' or checkout.currency == 'YEN' or checkout.currency == 'KES' or checkout.currency == 'KOR' or checkout.currency == 'LBP' or checkout.currency == 'MYR' or checkout.currency == 'MXN' or checkout.currency == 'NPR' or checkout.currency == 'NZD' or checkout.currency == 'NIO' or checkout.currency == 'NGN' or checkout.currency == 'PKR' or checkout.currency == 'CNY' or checkout.currency == 'PHP' or checkout.currency == 'SGD' or checkout.currency == 'LKR' or checkout.currency == 'CHF' or checkout.currency == 'TWD' or checkout.currency == 'TSH' or checkout.currency == 'THB' or checkout.currency == 'UGX' or checkout.currency == 'KWD' -%}
{% if template contains 'product' %}
{%- assign fa_product_price = fa_current_variant.price | 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 = fa_current_variant.price | money_without_currency | remove:'.' | replace: ',', '.' -%}
{% elsif template contains 'cart' %}
{%- assign fa_product_price = cart.total_price | money_without_currency | remove:'.' | replace: ',', '.' -%}
{% endif %}
{%- endif -%}

{%- if fa_product_id == 'default' -%}
{%- capture fa_product_id_value -%}shopify_{{ fa_product_id_alpha2_code }}_{{ product.id }}_{{ fa_current_variant.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'product_id' -%}
{%- capture fa_product_id_value -%}{{ fa_current_variant.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'parent_id' -%}
{%- capture fa_product_id_value -%}{{product.id }}{%- endcapture -%}
{%- elsif fa_product_id == 'sku' -%}
{%- capture fa_product_id_value -%}{{ fa_current_variant.sku }}{%- endcapture -%}
{%- endif -%}


<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-{{ fa_google_ads_audience_tag_id }}');
</script>

{% 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': [{
			'id': '{{fa_product_id_value}}',
      '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 FeedArmy 2021 Version 2.17 END -->

Checking The Results

Currently as of writing, Google Tag Assistant does not check which values are added in the gtag remarketing code. So you will need to look at the source code, to confirm.

Important!
Google Tag Assistant will show a red label if you have an ad blocker installed on your browser. Disable or remove the ad blocker to see a blue icon.

You can check the results manually by right-clicking on the product landing page then choose view page source and search for FeedArmy (ctrl+f), then simply check the values that are added. You should see something like below.

<!-- Google Ads Remarketing Tag By FeedArmy START -->
<!-- FeedArmy tutorial found at https://feedarmy.com/adding-google-adwords-remarketing-tag-to-shopify/ -->
<!-- Please add your Google Ads Audience Source Tag ID -->
<!-- Please add your alpha2 code, you can find it here: https://help.shopify.com/en/api/custom-storefronts/storefront-api/reference/enum/countrycode
<!-- set your product id values are default, product_id, parent_id, sku-->
<!-- ------------------------------------ -->
<!-- DO NOT EDIT ANYTHING BELOW THIS LINE -->
<!-- Global site tag (gtag.js) - Ads. -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456789"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-123456789');
</script>
<!-- Global site tag (gtag.js) - Ads. -->
<script>
  gtag('event', 'view_item', {
    'send_to': 'AW-123456789',
	'value': 490.00,
    'items': [{
	'id': 'shopify_US_244465464459_214781237805',
        'google_business_vertical': 'retail'
    }]
  });
</script>
<!-- Google Ads Remarketing Tag By FeedArmy END -->

Change Log

Need Help?
Do you have a question or need specialist support? Get in touch!

Exit mobile version