How To Setup Google Ads Dynamic Remarketing in Shopify?

Shopify Google AdWords Dynamic Remarketing Setup

If you are stuck setting up Google Ads (AdWords) Dynamic Remarketing scripts in your Shopify store, this simple guide will help you do it easily.

Without much ado, let me take you straight to the process…

  1. Step 1: Add a new Snippet for AdWords Dynamic Remarketing 
  2. Step 2: Call the Snippet you created in the theme file
  3. Step 3: Test your setup

Yes, you will only need to take just three simple steps. However, a bit of minute attention may be required so that you don’t break anything. Grab your coffee if it helps you to be attentive! Let’s get started…

Step 1: Add a new Snippet for Google Ads Dynamic Remarketing

  • Login to Shopify and go to Online Store > Themes > Edit HTML/CSS
  • Scroll to the bottom to the Snippet section in the left navigation bar
  • Click ‘Add a new snippet’ and give it the name – adwords-dynamic-remarketing
  • Paste the codes below and Save it.
  • Make sure to change the Conversion ID, AW-000000. You will need to go to your Google Ads account to set up a conversion action for Sales. Note the conversion ID from the code that Google gives you.

<!-- Global site tag (gtag.js) - Google Ads: 000000 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-000000"></script>
<script>
 window.dataLayer = window.dataLayer || [];
 function gtag(){dataLayer.push(arguments);}
 gtag('js', new Date());<!-- Event snippet for dynamic remarketing -->gtag('config', 'AW-000000');
</script>
{% if template contains 'index' %}
<script>
 gtag('event', 'page_view', {
 'send_to': 'AW-000000',
 'ecomm_pagetype': 'home'
 });
</script>
{% elsif template contains 'collection' %}
<script>
 gtag('event', 'view_item_list', {
 'send_to': 'AW-000000',
 'ecomm_pagetype': 'category'
 });
</script>
{% elsif template contains 'product' %}
<script>
 gtag('event', 'view_item', {
 'send_to': 'AW-000000',
 'ecomm_pagetype': 'product',
 'ecomm_prodid': '{{ product.id }}',
 'ecomm_totalvalue': '{{ product.price | money_without_currency | remove: ',' }}'
 });
</script>
{% elsif template contains 'cart' %}
<script>
 gtag('event', 'view_cart', {
 'send_to': 'AW-000000',
 'ecomm_pagetype': 'cart',
 'ecomm_prodid': [{% for item in cart.items %}'{{item.product.id}}'{% unless forloop.last %},{% endunless %}{% endfor %}],
 'ecomm_totalvalue': '{{cart.total_price | money_without_currency | remove: ',' }}'
 });
</script>
{% elsif template contains 'search' %}
<script>
 gtag('event', 'view_search_results', {
 'send_to': 'AW-000000',
 'ecomm_pagetype': 'searchresults'
 });
</script>
{% else %}
<script>
 gtag('event', 'page_view', {
 'send_to': 'AW-000000',
 'ecomm_pagetype': 'other'
 });
</script>
{% endif %}

 


Step 2: Call the Snippet you created in the theme file

  • Go to Shopify admin, Online Store > Themes.
  • Click Actions > Edit code.
  • Paste the code below, and try placing it near the top part of the <head> section.
  • Now, Save it.

The following code goes in the Theme.liquid file :

<!-- Google AdWords Dynamic Remarketing -->
{% include 'adwords-dynamic-remarketing' %}
  • And now Save it.

Next, you need to add the remarketing codes to your final order confirmation page as well so that the AdWords (Google Ads) system has insights about your sales.

Head to Settings > Checkout > Additional Scripts

Add the following script:

(Do not forget to change the Google Ads Conversion ID):


{% if first_time_accessed %}
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-000000"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'AW-000000');
</script>
<script>
gtag('event', 'purchase', {
'send_to': 'AW-000000',
'ecomm_pagetype': 'purchase',
'ecomm_prodid': [{% for item in checkout.line_items %}'{{line_item.sku}}',{% endfor %}],
'ecomm_totalvalue': {{ checkout.total_price | money_without_currency | remove:',' }}
});
</script>
{% endif %}

Congrats! You’re done.

Now download and install the Google Tag Assistant plugin for the Chrome browser. Go to your website, enable the plugin and check the script. It should be working well.

Common Issues:

Product IDs don’t match with what is being sent to Google Merchant Center.

 

By default, Google Shopping App in Shopify would create your Product IDs something like – shopify_AU_6722613280930_39804145631394. This is what is sent to Google Merchant Center. Here’s AU is the country code for your store, the first numeric part is Product ID, and the second one is the Variant ID.

Now, if the Product IDs in Merchant Center and on your site don’t match, Google Ads will throw errors and your Dynamic Remarketing campaigns won’t be able to show the right products in your ads.

Let’s fix it.

In the first part of the code mentioned on this page, locate the following block:

<script> gtag('event', 'view_item', { 
'send_to': 'AW-000000', 
'ecomm_pagetype': 'product', 
'ecomm_prodid': '{{ product.id }}', 
'ecomm_totalvalue': '{{ product.price | money_without_currency | remove: ',' }}' 
}); </script>

And find

'ecomm_prodid': '{{ product.id }}',

Now, replace ‘{{ product.id }}’ with ‘shopify_AU_{{ product.id }}_{{product.selected_or_first_available_variant.id}}’

Make sure to verify the country code. If your store country is India, it would be shopify_IN. You can log into your Google Merchant Center account and open a product to find the Product ID.

Next, locate the Cart page specific code block and make sure your product.id is –

‘ecomm_prodid’: [{% for item in cart.items %}’shopify_AU_{{item.product.id}}_{{item.variant.id}}'{% unless forloop.last %},{% endunless %}{% endfor %}],

Finally, fix it for the Purchase page. Go to Settings > Checkout from your Shopify Admin. Find the ecomm_prodid line and update it to become –

‘ecomm_prodid’: [{% for item in checkout.line_items %}’shopify_IN_{{item.product.id}}_{{item.variant.id}}’,{% endfor %}],

If you come across any issue or have any feedback, feel free to post it in the comment section below.

And yes, if someone you think needs help on how to set up Google Ads or AdWords Dynamic Remarketing in Shopify, you can share this post. :)

Updated: Jan. 2024.

Sharing is caring!

About the author

15 thoughts on “How To Setup Google Ads Dynamic Remarketing in Shopify?”

  1. it is a wonderful snap,I am looking for it
    By the way,How can have the audience list (searchresult) displayed in google ads
    default there are only shopping cart abandoners and past buyers

    1. It won’t be readily available. You need to create that list. If you have linked your Google Analytics and Google Ads accounts, any Audience list that you create in Analytics will be available in Google Ads as well. Go ahead and create a specific list for the audiences who used search on your site.

  2. I have followed above mentioned steps and now in my google ads account ecom_prodid parameter is showing in Audience sources menu. i think it is working very well but i want know that how many day it takes to solve erroe that “Issue: ecomm_prodid never received”.

  3. Reinier van der Poel

    Hi Ratan, thanks for the explanation. Question why do we remove the “,” in the piece of code ‘ecomm_totalvalue’: {{ checkout.total_price | money_without_currency | remove:’,’ }} ? This way my product values values are multiplied by x100? What would be the line of code if we don’t want to remove the “,”? Apart from that many thanks for the explanation very helpful.

    1. If you are talking about removing “,” where the line lasts, that’s how JS is written, the last line won’t have the comma. Your product value won’t be multiplied by 100. Let one Sale happen and check it.

  4. Thank you! But I got two questions left.

    1) Do I leave the conversion snipped in the checkout scrip beside the snipped for dynamic remarketing?

    2) Do I remove the global site tag, when I already had it implement in theme.liquid?

  5. Hi, I have implemented as suggested above, i can see the values generated in source code, but i couldnt find any values in console. can u help?

  6. Hi Ratan, thank you for this information!
    I’m trying to do the same, but with the updated remarketing naming (without ecomm), but i’m stuck – i don’t see it on the TYpage. Maybe you had this kind of issue?
    Would be really greatful for your help!

    1. There’s another way of implementing and that’s via Events. But you should not need that, the eComm works just fine. If you want specific issue, you can email me.

  7. Hi this is absolutely the best article on the internet about how to do this, great work!

    BUT, is it possible you could update the section on the “shopify_AU_xxxxx” ids to tell us how to modify the CHECKOUT code to also match the Shopify-Merchant Center feed ids?

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top