Adding Google Ads Remarketing Tag To Shopify

Adding 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 top right corner click on the 3dot menu and select Audience Manager from the Shared Library section

Google Ads Audience Manager

If you already have a remarketing code, skip this section and go to the next section with continue here.

Click on setup audience list

Google Ads Setup Audience List

Then click on setup tag

Google Ads Setup Tag

From the left hand, menu click on Audience Source and click on the 3dot menu and choose edit source within the Adwords tag section

Google Ads Audience Sources

Select the following (continue here)

  • Dynamic Remarketing
    • Collect specific attributes or parameters to personalize ads
  • Business Type
    • Retail
Google Ads Tag Data Source

Click on Install the tag yourself

Google Ads Install Tag Yourself

If you get a choice to choose the old or new one, click on the new one and copy the event code to a plain text editor. And 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.

Google Ads Source Tag ID

Step 2) Adding The Tracking Code To theme.liquid

Login to your Shopify Admin Panel

Shopify Login

Open up the theme editor by going to Online Store > Themes

Shopify Theme

Now choose Actions > Edit Code

Shopify Actions Edit Code

Click on theme.liquid inside the layout folder

Shopify Theme Liquid

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. If you’re in the US, then keep fa_prices_with_decimal_separator to true, if you are in a European country then change it to false.
  4. 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.11 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' %}

<!-- if you have prices such as 1,000.00 set below to true, if you have prices such as 1.000,00 set below to false -->
{% assign fa_prices_with_decimal_separator = true %}

<!-- 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 -->
<!-- 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 FeedArmy Version 2.11 END -->

Now go to Settings > Checkout

Shopify Checkout Settings

Scroll down till you see Order Processing > Additional scripts

Shopify Checkout 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. If you’re in the US, then keep fa_prices_with_decimal_separator to true, if you are in a European country then change it to false.
  4. 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 Version 2.11 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' %}

<!-- if you have prices such as 1,000.00 set below to true, if you have prices such as 1.000,00 set below to false -->
{% assign fa_prices_with_decimal_separator = true %}

<!-- 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 -->
<!-- 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 %}

// {{ checkout.total_price | money_without_currency | remove:',' }}

{% 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 FeedArmy Version 2.11 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/kb/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
<!-- if you have prices such as 1,000.00 set below to true, if you have prices such as 1.000,00 set below to false -->
<!-- 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 -->

Need Help?

Changelog

Added support for parent product id's
Did not start tracking all changes