Re: Google dynamic remarketing tag code

Need help with Google dynamic remarketing tag code for Shopify?

Teslyar
Tourist
9 0 1

Hi,

 

Does anyone have the hardcoded Google dynamic remarketing code for Shopify that they can share with me for theme.liquid and checkout?

 

I haven't seen any templates around apart from some using the old event snippets.

 

It would be super helpful for others in the same position too.

 

Thank you.

Replies 11 (11)

Josh_Uebergang
Shopify Partner
1022 44 276

@Teslyar, have you seen the dynamic remarketing code in my Google Shopping book? Most code people give out is just the dang same one Google suggests, which is of little help for Shopify.

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

Thanks. I've added the code, changed what needs to be changed and linked the attributes via google analytics to google ads. 

 

Let's see what hits we get after 24 hours when it updates.

Teslyar
Tourist
9 0 1

@Josh_Uebergang Your code appears to be missing the 'home' pagetype. Do you have additional script for this?

 

Kind regards,

 

Yuriy

Josh_Uebergang
Shopify Partner
1022 44 276

I believe the homepage offers no value in dynamic remarketing. Everyone visits the homepage which means the products they get displayed there are not personalized so what's the point of trying to target people with them? If you want to retarget home page visitors, you can build your own audience in analytics of people who visit the home page.

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

Hi @Josh_Uebergang ,

 

Could you please let me know if the following code and the way of inserting it, is ok for the dynamic remarketing?

I have added all three custom dimensions ecomm_prodid, ecomm_pagetype and ecomm
_total value in Universal GA, then I added also the dynamic atribute for retail.

Screenshot 2021-06-12 at 11-53-17 Analytics.png

  

Once added it requires inserting the following JS snippet:

var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension1', dimensionValue);

 

So what I would like to do, is to add into Shopify/Preferences/Google Analytics/Additional Google Analytics JavaScript section the following code:

var ecomm_prodid = 'shopify_RO_{{ product.id }}_{% if product.variants.first.id %}{{ product.variants.first.id }}',{% else %}{{ product.variants.id }}',{% endif %}';
ga('set', 'dimension1', ecomm_prodid);
var ecomm_pagetype = '{{ template }}';
ga('set', 'dimension2', ecomm_pagetype);
var ecomm_totalvalue = '{{ total_price | money_without_currency | replace: ",", "." }}';
ga('set', 'dimension3', ecomm_totalvalue);

 

Thank you

RaulD
Tourist
5 0 0

Hi @Josh_Uebergang,

 

I have seen and implemented your guide  on dynamic remarketing. Thanks so much for sharing such valuable info.

One question:

On pre-requisites setup, at second point, you mentioned to add Google Analytics from this tutorial https://www.digitaldarts.com.au/google-ads-conversion-tracking-shopify.

So on checkout / order processing /additional scripts I will need to add also the script from GA setup on top of the Remarketing code for checkout?

In such case would it be ok to use the following code?

many thanks in advance for your help

<!-- START Google Ads dynamic remarketing by DigitalDarts.com.au v1.5 -->
{% assign UA-ID = "UA-PROPERTY_ID" -%}
{%- assign AW-ID = "AW-GOOGLE_CONVERSION_ID" -%}
{%- assign product-id = "product-id_variant-id" -%}
{%- assign product-id-prefix = "shopify_EU_" -%}
{%- assign price-decimal-fs = false -%}

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ UA-ID }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ UA-ID }}', { 'send_page_view': false, 'custom_map': {'dimension1': 'ecomm_prodid', 'dimension2': 'ecomm_pagetype', 'dimension3': 'ecomm_totalvalue'} });
gtag('config', '{{ AW-ID }}');
</script>

<!-- START Event snippet for Sales conversion page -->
{% if first_time_accessed %}
<script>
gtag('event', 'conversion', {
'send_to': 'AW-GOOGLE_CONVERSION_ID',
'value': {{ checkout.total_price | money_without_currency}},
'currency': '{{ order.currency }}',
'transaction_id': '{{ order.order_number }}'
});
</script>
{% endif %}
<!-- END Event snippet for Sales conversion page -->

<script>
gtag('event', 'Dynamic Remarketing', { 'ecomm_pagetype': 'purchase'
{%- if product-id == "product-id_variant-id" -%}
, 'ecomm_prodid': [{% for item in checkout.line_items limit:3 %}'{{ product-id-prefix }}{{ item.product_id }}_{{ item.variant_id }}'{% unless forloop.last %}, {% endunless %}{% endfor %}]
{%- elsif product-id == 'variant-id' -%}
, 'ecomm_prodid': [{% for item in checkout.line_items %}'{{ product-id-prefix }}{{ item.variant_id }}'{% unless forloop.last %}, {% endunless %}{% endfor %}]
{%- elsif product-id == 'sku' -%}
, 'ecomm_prodid': [{% for item in checkout.line_items %}'{{ product-id-prefix }}{{ item.sku }}'{% unless forloop.last %}, {% endunless %}{% endfor %}]
{%- endif -%}
, 'ecomm_totalvalue': {% if price-decimal-fs == true -%}{{ checkout.total_price | money_without_currency | remove: ',' }}{% else %}{{ checkout.total_price | money_without_currency | remove: '.' | replace: ',', '.' }}{%- endif -%}
, 'non_interaction': true });
</script>
<!-- END Google Ads dynamic remarketing by DigitalDarts.com.au v1.5 -->

Jaspertronics
New Member
4 0 0

Hello Josh

I hope I reviewed everything and did not miss this - I am sure you have repeated yourself often as your threads are all of the top google results!

In any event I have an issue with dynamic remarketing and I was informed by the google tag team as to why - but I cannot confirm the dynamic values I need.

The code in theme.liquid:

<script>
gtag('event', 'page_view', {
'send_to': 'AW-xxxxxxxxx',
'value': 'replace with value',
'items': [{
'id': 'replace with value',
'google_business_vertical': 'retail'
}]
});
</script>

 

The code above obviously is not complete as it has variables not set. How do I set the following two lines to make that dynamic remarketing work?

What is the value to replace with?

'value': 'replace with value',
'id': 'replace with value',

 

Thank you tremendously for your response!


The error that lead me down this path, if that is helpful:

"""""The values received from your audience source for the required parameter for your business type may be formatted differently than in your feed or missing from your feed. Click "Download" to see the top values received for the required parameter that aren't matching your feed. Note that Google Analytics refers to parameters for remarketing as Dynamic Attributes. Download

Issue: 98% of id values received in the past day didn't match your feed"""""

WeDoTheStuff
New Member
20 0 0

Hey @Jaspertronics,

We understand it could be a pain in the @#! to implement Google's dynamic remarketing pixel, so that's why we've created an app to do it for you.

It fires the right snippet with the right attributes and values every time, including 'value': 'replace with value',
'id': 'replace with value' with the right dynamic params.

Check it out.

https://apps.shopify.com/dynamic-remarketing

If there's anything to customize on your site from our end to make it work, we can do it for you.

Jaspertronics
New Member
4 0 0
What about all of the code already dispersed throughout the site, Is this
cleaned up as well?


Dabrowka
Tourist
18 0 1

Hi @Josh_Uebergang I used the code from your google shopping book and unfortunately I see that the ecomm_* parameters don't show any hits. Is that right?

Dabrowka_0-1707730976775.png

 

Josh_Uebergang
Shopify Partner
1022 44 276

Make sure the ID structure in the code match to your shopping feed ID structure.

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