How to properly install Google Dynamic Shopping Remarketing?

New Member
3 0 0

Hi Josh

 

I deleted the last endif code and Ican save now. Going to see if it is working.

 

Also I already had tracking code set in checkout - additional script by this guide:

https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/tracking-adwords-conversion...

 

ga-snippet-setup-dynamic-value.png

 

Do I need to remove this code or just keep it together with your code?

 

Thanks

0 Likes
Highlighted

If that's a screenshot of your code, it won't work given it's the wrong Google Ads send_to variable (Shopify just provided an example). But yes, you don't want to double up on the conversion code.

Run Google Shopping ads? Get the free definitive guide to Google Shopping for Shopify (no optin required): https://www.digitaldarts.com.au/google-shopping
0 Likes
New Member
3 0 0

Hi Josh

 

It's the screenshot from the shopify guide I referred to :)

 

So I don't need this code if I'm doing dynamic remarketing with your code, right?

0 Likes

Yes, you don't need to double up on the conversion tracking code.

Run Google Shopping ads? Get the free definitive guide to Google Shopping for Shopify (no optin required): https://www.digitaldarts.com.au/google-shopping
0 Likes
New Member
1 0 0

Hi @Josh_Uebergang,

 

Thanks a lot for your guide, it's been incredible helpful. But i have some doubts:

1. Where can i check what my store is sending product ID to the merchant center (for ex. SKU or other)

2. Where in the code should i install the global tag?, i see in the guide you tell the code to be installed in the new snippet, but should also be wrote on the liquid theme, below <head>? And what would be specifically the Analytics Global tag for this?

 

Hope you can help me, thanks a lot.

0 Likes

Hi,

 

Please use this below code, I have corrected that, this will work :-

 

{% if template contains 'product' or template contains 'collection' or template contains 'index' or template contains 'search' or template contains 'cart' %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-PROPERTY_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-136759308-1', {'send_page_view': false, 'custom_map': {'dimension1': 'Product SKU', 'dimension2': 'ecomm_pagetype', 'dimension3': 'ecomm_totalvalue'}});
gtag('config', 'AW-747247553');
</script>

<script>
gtag('event', 'page_view', {
'ecomm_pagetype': {% if template contains 'collection' %}category{% elsif template contains 'search' %}searchresults{% elsif template contains 'product' %}product{% elsif template contains 'cart' %}cart{% elsif template contains 'index' %}home{% endif %},
{% if template contains 'product' %}
'Product SKU': 'shopify_IN_{{ product.id }}_{% if product.variants.first.id %}{{ product.variants.first.id }},{% else %}{{ product.variants.id }}{% endif %}',
'ecomm_totalvalue': {{ product.price_min | money_without_currency | replace: ',', '.' }},
{% elsif template contains 'cart' %}
'ecomm_prodid': [{% for item in cart.items %}'shopify_US_{{ item.product_id }}_{{ item.variant_id }}'{% unless forloop.last %},{% endunless %}{% endfor %}],
'ecomm_totalvalue': {{ cart.total_price | money_without_currency | replace: ',', '.' }},
{% endif %}
'non_interaction': true
});
</script>
{% endif %}

 

For more details you can contact me on my email-id arpansrivastava@cedcommerce.com

Arpan Srivastava
Store Analyst

Skype id-live:danbakker_2
0 Likes
New Member
3 0 0

Hi thank you for your guide. I have two questions.

 

1. I am having the same issue as a user above. When i add this {% endif %}  at the end of your script per your instructions, shopify will not allow me to save the dynamic-remarketing.liquid. Do we need to have {% endif %} at the end?

 

2. Can i remove the GA tracking from the preferences section when implementing your setup?

Capture.JPG

0 Likes
New Member
3 0 0

Hi and thank you for your guide (https://www.digitaldarts.com.au/google-shopping/merchant-center-programs). I have two questions I hope you can help me with.

 

I am having an issue with your code. The {% endif %}  at the end of your script will not allow me to save the dynamic-remarketing.liquid. file in shopify. I tried to get around this using Google Tag Manager but GTM also said there is an issue wth the code.

  1. {% if template contains 'product' or template contains 'collection' or template contains 'index' or template contains 'search' or template contains 'cart' %}
  2. <!-- Global site tag (gtag.js) - Google Analytics -->
  3. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-PROPERTY_ID"></script>
  4. <script>
  5.   window.dataLayer = window.dataLayer || [];
  6.   function gtag(){dataLayer.push(arguments);}
  7.   gtag('js', new Date());
  8.   gtag('config', 'UA-PROPERTY_ID', {'send_page_view': false, 'custom_map': {'dimension1': 'ecomm_prodid', 'dimension2': 'ecomm_pagetype', 'dimension3': 'ecomm_totalvalue'}});
  9.   gtag('config', 'AW-GOOGLE_CONVERSION_ID');
  10. </script>
  11.  
  12. <script>
  13.   gtag('event', 'page_view', {
  14.     'ecomm_pagetype': '{% if template contains 'collection' %}category{% elsif template contains 'search' %}searchresults{% elsif template contains 'product' %}product{% elsif template contains 'cart' %}cart{% elsif template contains 'index' %}home{% endif %}',{% endif %}
  15.     {% if template contains 'product' %}
  16.     'ecomm_prodid': 'shopify_US_{{ product.id }}_{% if product.variants.first.id %}{{ product.variants.first.id }}',{% else %}{{ product.variants.id }}',{% endif %}
  17.     'ecomm_totalvalue': {{ product.price_min | money_without_currency | replace: ',', '.' }},
  18.     {% elsif template contains 'cart' %}
  19.     'ecomm_prodid': [{% for item in cart.items %}'shopify_US_{{ item.product_id }}_{{ item.variant_id }}'{% unless forloop.last %}, {% endunless %}{% endfor %}],
  20.     'ecomm_totalvalue': {{ cart.total_price | money_without_currency | replace: ',', '.' }},
  21.     {% endif %}
  22.     'non_interaction': true
  23.   });
  24. </script>
  25. {% endif %}

 

My second question is if I can remove the Google tracking in the preferences section of shopify with your implementation.Capture.JPG

0 Likes

1. Delete the very last {% endif %} on line 14. I updated the code this year and think you found a mistake by pointing this out.

2. No, don't remove it. It is not a substitute for Shopify's native GA setup, but it is a complement by adding dynamic remarketing to it.

Run Google Shopping ads? Get the free definitive guide to Google Shopping for Shopify (no optin required): https://www.digitaldarts.com.au/google-shopping
0 Likes
New Member
3 0 0

Thanks, I was finally able to save the file but now im not seeing the events fire on the data layer via GTM but i see it in the view source code (see images).   I was however able to save this stripped down version below earlier which was showing the data layer variables in GTM, just not sure if it's ok like this. I stripped out most of the if statements.

 

 

Capture.PNGCapture2.PNG

 

 

This code seems to be working but I dont know how to check Hits in real time so I will wait until tomorrow to see the audience sources in Google Ads for hits. 

<!-- Global site tag (gtag.js) - Google Analytics -->

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-109048311-1"></script>

<script>

  window.dataLayer = window.dataLayer || [];

  function gtag(){dataLayer.push(arguments);}

  gtag('js', new Date());

  gtag('config', 'UA-109048311-1', {'send_page_view': false, 'custom_map': {'dimension1': 'ecomm_prodid', 'dimension2': 'ecomm_pagetype', 'dimension3': 'ecomm_totalvalue'}});

  gtag('config', 'AW-813447222');

</script>

 

<script>

  gtag('event', 'page_view', {

    'ecomm_pagetype': '{% if template contains 'collection' %}category{% elsif template contains 'search' %}searchresults{% elsif template contains 'product' %}product{% elsif template contains 'cart' %}cart{% elsif template contains 'index' %}home{% endif %}',

    {% if template contains 'product' %}

    'ecomm_prodid': 'shopify_US_{{ product.id }}_{% if product.variants.first.id %}{{ product.variants.first.id }}',{% else %}{{ product.variants.id }}',{% endif %}

    'ecomm_totalvalue': {{ product.price_min | money_without_currency | replace: ',', '.' }},

    {% elsif template contains 'cart' %}

    'ecomm_prodid': [{% for item in cart.items %}'shopify_US_{{ item.product_id }}_{{ item.variant_id }}'{% unless forloop.last %}, {% endunless %}{% endfor %}],

    'ecomm_totalvalue': {{ cart.total_price | money_without_currency | replace: ',', '.' }},{% endif %}

    'non_interaction': true

  });

</script>

0 Likes