How to add Google Analytics remarketing code on Shopify ?

Highlighted
New Member
2 0 1

Hi,

I would like to add Google Analytics remarketing tag in Shopify in order to run dynamic retargeting campaigns. I created dynamic attributes on Analytics in order to get the ecomm_prodid, ecomm_pagetype and ecomm_totalvalue.

 So now I have a new Analytics tag that I need to implement on my site :

    <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX', 'auto'); 
  ga('set','dimension1','{{ product.id }}'); 
  ga('set','dimension2','{{ template }}'); 
  ga('set','dimension3','{{ product.price_min | money_without_currency }}');
  ga('send', 'pageview');

</script>

But if I add it just before the </body> of theme.liquid I get an error in tag assistant saying that the Analytics tag is fired twice. I also tried to implement on preferences>Google Analytics>Additional Google Analytics JavaScript but it didn't work either.

Does anyone know how to implement it properly ?

Thanks,

Marion

1 Like
Highlighted
Shopify Staff
Shopify Staff
259 3 66

Hi, Marion! 

Lisa here from the Shopify Support Team. 

Sure, to add Google Analytics remarketing tag in Shopify in order to run dynamic retargeting campaigns, there are a few steps you have to follow. 

If you install it in the code, as well as in the preferences within Shopify, it will be firing to the same place, which is likely why you're getting the error that it is firing twice. 

Here's a great article with recent & detailed instructions ( 12th February 2018 ) on how to set up your remarketing tag properly in Shopify! 

I suggest starting again what you've done to follow the above instructions step by step. 

Once you've done that, here's more info from Google on dynamic remarketing to get the most out of these ads:

Hope this helps & is what you were after! ?

- Lisa 

Lisa | Social Care @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
Highlighted

Firstly, are you happy to do it via Google AdWords? There are advantages and disadvantages of each. If so, you can just follow Lisa's suggestion.

Otherwise, you can do it via Google Tag Manager for Google Analytics. I have created the start of it for you:

<script>
dataLayer = [{
  {% if template contains 'cart' %}
    'ecomm_prodid': [{% for item in cart.items %}'{{ item.variant.id }}'{% unless forloop.last %}, {% endunless %}{% endfor %}],
    'ecomm_pagetype': 'cart',
    'ecomm_totalvalue': {{ cart.total_price | money_without_currency  | remove: ','  }}
  {% elsif template contains 'collection' %}
...

It's worth noting that the ecomm_prodid needs to match the value of IDs in your shopping feed. If you use a feed solution like DataFeedWatch, this can be set to whatever you want. I typically use the variant_id. The Shopify Google Shopping app will usually have a value like yourCountryCode_productID_variantID. You can get the ID structure from the Merchant Center if you are unsure what it is.

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

Hi,

Thank you both for your quick feedbacks. I chose to do it via Google Adwords because it seemed to be the easiest way. Thanks for the article it was really helpfull.

Marion

0 Likes
Highlighted
New Member
1 0 1

Joshua, I saw your resposne to this and have a question.

I used your article on adding Adwords Conversion tracking to Shopify (https://www.digitaldarts.com.au/google-ads-conversion-tracking-shopify) and in it you mention that the gtag.js code needs to have { 'send_page_view': false } in order to avoid sending duplicate page views.

I have the standard GA setup in Shopify. That is I pasted my GA code into the Shopify admin tool via Online Store -> Preferenes. It's not setup via tag manager or pasting it directly into my theme.

My question is (and I've asked FeedArmy too but haven't heard back) does FeedArmy's method for setting up Adwords Dynamic remarketing (https://feedarmy.com/kb/adding-google-adwords-remarketing-tag-to-shopify/) also require { 'send_page_view': false } in order to avoid duplicate page views?

I thought the answer might be yes because with FeedArmy's method I have to put the gtag.js code on every page of the site which would duplicate the GA code that is automatically added via Online Store -> Preferences?

One more issue, if { 'send_page_view': false } is added would that cause problems because FeedArmy's event tag in the code - "gtag('event', 'page_view', {..." -  seems to be a page view event? So the "false" would casue the event not to be sent? Or maybe that's not how it works?

Thanks for the help. Really appreciate it.

1 Like
Highlighted
Shopify Partner
18 0 4

Hi Marion,

Please find the steps below to go through the add Google Analytics remarketing code on Shopify :
Step 1: Enable Advertiser Features in Google Analytics : Sign into the Google Analytics account for your website and click on the Admin tab at the top. On the column labeled Property, click on the tab that says Property Settings. About half way down the page, you will see a section called Advertiser Features, set Enable Advertiser Features to ON.
Step 2: Create a campaign in Google Adwords : Log into Google Adwords and click on the red +Campaign button and select Display Network Only
Step 3: Add the Google Remarketing Tag to your theme.liquid in Shopify : To insert the code, log into the back end of your Shopify store. Click theme, then customize theme, and then EDIT HTML/CSS. Click on theme.liquid and find where the </body> tag is in the html. Click on the line directly above this, and insert the remarketing tag. You do not need to include the Google Remarketing Tag header, you can insert just the javascript code.

Also, there is URL which can help you to move further : https://www.getelevar.com/how-to/setup-google-dynamic-remarketing-on-shopify/

 

Thanks,

1 Like
Highlighted
New Member
1 0 0

Can anyone explain to me please,  if the Additional Google Analytics JavaScript space is something necessary if I have an e-commerce store or if it's only needed if I want special tracking in x page? Also, where do I find this code or is the same as the one that google analytics gives you? HELP! Sorry if this is to basic but I really can´t find a straigh answer on this matter since I am not so familiar with all this.


@Akanksha_Singh wrote:

Hi Marion,

Please find the steps below to go through the add Google Analytics remarketing code on Shopify :
Step 1: Enable Advertiser Features in Google Analytics : Sign into the Google Analytics account for your website and click on the Admin tab at the top. On the column labeled Property, click on the tab that says Property Settings. About half way down the page, you will see a section called Advertiser Features, set Enable Advertiser Features to ON.
Step 2: Create a campaign in Google Adwords : Log into Google Adwords and click on the red +Campaign button and select Display Network Only
Step 3: Add the Google Remarketing Tag to your theme.liquid in Shopify : To insert the code, log into the back end of your Shopify store. Click theme, then customize theme, and then EDIT HTML/CSS. Click on theme.liquid and find where the </body> tag is in the html. Click on the line directly above this, and insert the remarketing tag. You do not need to include the Google Remarketing Tag header, you can insert just the javascript code.

Also, there is URL which can help you to move further : https://www.getelevar.com/how-to/setup-google-dynamic-remarketing-on-shopify/

 

Thanks,


 

0 Likes
Highlighted
Excursionist
30 0 15

Hey WIll32 did you get this sorted, would like to hear the solution if you can share, thanks in advance.

0 Likes
Highlighted
New Member
1 0 0

Hi guys, we are facing a similar problem - 

 

We have a Google Ad Tag that is firing on our Shopify Home and Product Page, but not our checkout page and we are not sure where this code is setup? We investigated the Shopify code and couldn't find any code relating to the AdWords within the <head> section. We also investigated if the apps set up on Shopify are causing this problem and it looks like it is not.  Please help 

0 Likes