Marketing

Shopify Marketing Analytics – Complete How-To Guide

This Shopify specific guide is continually updated with our best practices for common marketing analytics services like Adwords and Facebook.

Shopify Marketing Analytics – Complete How-To Guide

last updated 7/13/2018

Keeping up to date with all the changing requirements of marketing pixels, tags, tracking, etc can be overwhelming!

This is the process that I personally follow in the majority of marketing analytics audits or implementations for Shopify stores. This is constantly updated so be sure to bookmark and visit if you’re curious if anything has changed!

I’m happy to make edits to this if you have suggestions or you find inaccuracies. I’m not perfect..and I may be missing something that doesn’t work for some stores.

Here are the steps:

  1. Download GTM Container
  2. Install GTM on Shopify
  3. Create AdWords Conversions
  4. Configure Dynamic Remarketing Data
  5. Setup Facebook Conversion Tracking
  6. Google Analytics Property Settings
  7. Google Analytics View Settings

Step 1: Download/Setup Tags, Triggers, and Variables

Download our container here.

Here is what this contains:

  1. (5) Tags for Remarketing Events*
  2. (3) Tags for Google AdWords conversion events
  3. (8) custom variables to be used in these tags
  4. (7) custom variables from the thank you page that contains order level data to be used in other conversion tracking (as needed)

gtm container

If you already have Google Tag Manager setup then you might need to carefully select which tags you’d like to use from my container.

* There are two options to push dynamic remarketing data to Adwords shown in Step 4 below. If you decide to go the non-GTM route then you can pause/delete these Remarketing tags in GTM.

To import this container:

  1. Go to GTM > Your Account > Admin
  2. Click Import Container
  3. Choose “Merge” as your Import option
  4. Review conflicts, if any, that Google shows before finishing import. If you have conflicts then review your existing tags or variables current use.
  5. Import!

Be sure to select MERGE container, not overwrite!

gtmimport

Once you’ve completed this step or verified you have these already then move on to step 2. Steps 3+ assume you have these basic triggers and variables already available in GTM!

Step 2: Install Google Tag Manager on Shopify

You have two options:

Option a: Via Your Theme

If you’re on Shopify Plus and you have access to your checkout theme file then this step will work fine for you. You’ll just need to (or have your developers) insert your GTM snippet at the top of your theme.liquid (or similar)and your checkout liquid template:

And then the <noscript> version can go here:

gtm script for shopify

Option b: Via the Google Analytics Additional Javascript

This is the easy setup that works when wanting to have GTM on checkout pages within non Shopify Plus stores. You just copy your GTM snippet without the opening and closing <script> tags here:

Shopify GTM Additional Scripts

That’s it; you’ll then have tracking across all pages. You can see my full how to install Shopify & GTM installation here.

Step 3: Setup Google AdWords Conversions

This requires a few steps:

  1. Create (4) conversions in Google AdWords
  2. Setup conversion script in Shopify admin

Create conversions in AdWords

It’s a good idea to set up conversions to track key actions like viewing products, adding to cart, or viewing checkout. This will allow you to dig deeper into your campaign performance besides relying solely on transactions only.

Inside of Adwords (the new version) click on the wrench icon in the top navigation and go to Conversions:

adwords conversions

Then create a new conversion. We’ll use an example of viewing a product page:

custom conversion in adwords

The settings above will likely be unique to your business.

Once you’re done then click the Use GTM option which will give you your conversion ID and Label:

adwords conversion tracking event

And then head on over to GTM and update your Adwords Conversion Tag with your ID, label, and verify you have the proper trigger assigned (which it should already be set up for you):

adwords gtm conversion for product views

Repeat this step for Add to Cart and Initiate Checkout views.

Setup AdWords conversion script in Shopify admin

Call me paranoid, but I still prefer to set Adwords conversion tracking within the Shopify admin. There is less of a chance this configuration is going to break so it gives me peace of mind! But in theory you can set this up via GTM as well (I show how to setup conversion tracking via gtm here).

In Adwords, create a new conversion purchase event (or view an existing):

adwords purchase event

And grab each version of your tag requirements as shown below.

Global gtag.js:

purchase gtag

Event snippet:

purchase event

Copy these two scripts into their own file (maybe you’re using a text editor?), and then replace the items in bold to match your own unique variables:

{% if first_time_accessed %}

<!-- Global site tag (gtag.js) - Google AdWords: 123456789 -->
<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>

<!-- Event snippet for Google Adwords Purchase Conversion conversion page -->
<script>
 gtag('event', 'conversion', {
 'send_to': 'AW-123456789/z3o0CM_I4WkQ38PLvQM',
 'value': {{ total_price | money_without_currency | remove: ',' }},
 'currency': 'USD',
 'transaction_id': '{{order.order_number}}'
 });
</script>

{% endif %}

And then copy this into your additional scripts setting for checkout pages:

additional scripts adwords conversions

That’s it!

You now have 4 custom conversions setup for Google AdWords.

Step 4: Configure Dynamic Product Remarketing Data

This is usually where things can get very confusing for people! There are a few preconditions for this to “work” they way you expect (where customers see display campaigns with products they viewed, etc).

  1. You need a Google Merchant account with a valid product feed
  2. You need a campaign in AdWords where you create dynamic remarketing ads based on your product feed
  3. You need to associate your customer behavior to key onpage events like viewing product, cart, etc (this is what I’m showing how to do!)
  4. The ecomm_prodid that is sent to AdWords in step 3 needs to match the product ID of your product feed from step 1

I’m going to show step 3 – how to push key onsite parameters for retail audiences from your website to AdWords.

There are two options:

  1. Implement within your theme (e.g. theme.liquid or similar file that covers every page of your site)
  2. Implement via GTM

Option 1: How to implement within your theme:

  1. Modify the bold items in the snippet below to match your own Adwords IDs
  2. Implement into your theme.liquid file, preferably at the bottom of your <head> section

Very important: every website is different. I can’t promise this copy/paste will work in your store. It’s also a risk copy and pasting code from a blog (like this!) directly into your theme. If you have a developer, vet with them first. If you have questions please leave a comment below and I’ll help as best I can.

<!-- Global site tag (gtag.js) - AdWords: -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-xxxxxxx"></script>
<script>
 window.dataLayer = window.dataLayer || [];
 function gtag(){dataLayer.push(arguments);}
 gtag('js', new Date());

gtag('config', 'AW-xxxxxxx');
</script>
{% if template contains 'index' %}
<script>
 gtag('event', 'page_view', {
 'send_to': 'AW-xxxxxxx',
 'ecomm_pagetype': ‘home’
 });
</script>
{% elsif template contains 'collection' %}
<script>
 gtag('event', 'page_view', {
 'send_to': 'AW-xxxxxxx',
 'ecomm_pagetype': 'category'
 });
</script>
{% elsif template contains 'product' %}
<script>
 gtag('event', 'page_view', {
 'send_to': 'AW-xxxxxxx',
 'ecomm_pagetype': 'product',
 'ecomm_prodid': '{{ product.id }}',
 'ecomm_totalvalue': '{{ product.price | money_without_currency | remove: ',' }}'
 });
</script>
{% elsif template contains 'cart' %}
<script>
 gtag('event', 'page_view', {
 'send_to': 'AW-xxxxxxx',
 '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', 'page_view', {
 'send_to': 'AW-xxxxxxx',
 'ecomm_pagetype': 'searchresults'
 });
</script>
{% else %}
<script>
 gtag('event', 'page_view', {
 'send_to': 'AW-xxxxxxx',
 'ecomm_pagetype': 'other'
 });
</script>
{% endif %}

Option 2: Implement via GTM

Google states that you don’t need to deploy the global gtag snippet if you already have Google Tag Manager installed, however in my experience when the gtag.js is not installed separately I have seen large(r) inconsistencies in data.

So for now, I configure these tags together in Google Tag Manager and will cover the entire site except the thank you page since we have that covered in the previous step #3.

Basically what we’re doing here is setting a sitewide gtag.js which is used for data collection to capture remarketing audiences, custom events, custom conversions, etc. And then sending the dynamic remarketing event parameters with the sitewide gtag.js script.

If you downloaded the GTM container in step 2 then you only need to swap out the value in the {{needs updating – adwords id}} variable to allow for testing:

variable to change

A few important notes:

  1. Google does not differentiate between “cart” and “checkout” in their instructions so I’ve chosen to send the “cart” event hits on checkout views. My reason for this is I’m already sending an event for add to cart hits and many mini-carts today send users straight to the checkout (bypassing the normal cart page).
  2. Everything should work in GTM and follow Google’s instructions EXCEPT for cart ids. I’m working on a solution for this and will update the GTM container when completed.

There are additional steps required in Google Analytics that I have outlined in this related guide configuring dynamic remarketing with Shopify. If you’re going GTM route for this then please review this guide.

Step 5: Setup Facebook Conversions and Tracking

Hopefully you don’t need to do anything outside of the default FB pixel setup within the Shopify Admin:

default shopify facebook pixel

This setup will automatically track the following events by default:

  1. View Content (category and product pages)
  2. Add to Cart
  3. Initiate Checkout
  4. AddPaymentInfo
  5. Purchase
  6. Search

Then you’ll want to connect a catalog to Facebook so you can take advantage of dynamic product remarketing as well.

One potential problem is when it comes to matching up the product content to the product catalog you associate in Facebook. If you’re using the FB pixel helper and see this content warning:

facebook catalog mismatch warning

..then you might be experiencing this issue. The content_ids aka product IDs that are being pulled into this are your internal Shopify product IDs, not your own SKUs, barcode/UPC, or other custom IDs. So if you’re uploading a catalog to Facebook (or using your Google Shopping feed) and the id’s for these products are using anything besides the Shopify ID then you will likely get this mismatch warning.

If you’re using a feed for Google Shopping I don’t recommend changing the id’s to be your Shopify id’s for Google and Facebook at risk of losing out on mashing data from different sources to product profit reports by SKU.

So how do you fix this?

  1. You can go the route of recreating the Facebook pixel and event tracking in GTM
  2. Create/update your Facebook catalog to include ids that match your Shopify product IDs. If you’re using the native Shopify Facebook channel connection and/or apps like this then this should be automated for you.

Step 6: Audit Google Analytics Property Settings

In Google Analytics, “Properties” are where the unique UA-###### is assigned.

In this quick review, I’m looking for the following:

  1. Are demographic and interest reports enabled
  2. Is Search Console connected
  3. Do you have proper referral exclusion URLs defined so you don’t lose out on marketing or campaign attribution
  4. Are at least a few dynamic audiences created (for use in AdWords)
  5. Are the proper dynamic remarketing attributes created

There are other settings like UserID, etc, but these are a bit more advanced.

Search Console:

If this is not configured then this leads me down the path of ensuring Google Search Console is setup properly for your organic search analytics (very important!).

Referral Exclusion URLs:

At the minimum you should have:

  • your own domain (e.g. ‘.getelevar.com’)
  • checkout.shopify.com
  • paypal.com

And then if you have any additional custom payment methods (like Affirm) then I’d set these up there as well. You want to see transaction data attributed (both in assists and last click) back to your true marketing sources so you can make more informed marketing decisions.

Dynamic Audiences:

This is where you can use Google Analytics data to create custom audiences in your AdWords account.

This will be unique per client but the basics should cover:

  1. New Users – 7 Days (to remarket to “hot” visits)
  2. New Users, > 1 Session – 30 Days (to remarket to engaged visits)
  3. Users who Added to Cart, $0 Revenue – 30 Days (to remarket to cart abandoners)
  4. Users who Viewed Product, $0 Revenue – 30 Days (to remarket to product viewers)
  5. Users with Revenue > $0 – 365 days (to remarketing to existing customers)

There are so many possibilities here, but these cover large macro audience groups.

Dynamic Remarketing Attributes:

If you are implementing dynamic remarketing via Google Tag Manager (as shown earlier in this article) then this is a required option that is two steps:

  1. Create custom dimensions for each ecomm retail attribute (shown on left side of image below)
  2. Map these custom dimensions to the dynamic retail attributes shown on right side of image

dynamic attribute setup for shopify

If these are not set then I’ll usually review AdWords audience sources to see if the ecomm data is being pushed through other means.

Click here to view a more detailed walk through of property settings as part of my Google Analytics Audit for Shopify stores.

Step 7: Audit Google Analytics View Settings

The Basics

In a similar process as property settings, I will double check a few common settings:

  1. Is there a single view only or more than one? At the minimum I look for filtered, test, and a raw data view.
  2. In the Exclude URL query parameters: if this is empty then I’ll expect to get quite a bit of dirty page data even if just from utm parameters at the end of URLs.
  3. Is bot filtering enabled
  4. Is Adwords connected to the main filtered view
  5. Is site search tracking setup
  6. Are add to cart, viewed product, checkout started, checkout completed goals created (at the minimum)?
  7. Is Enhanced eCommerce reporting enabled

Custom Filters

This is another section that is subjective however I’m usually looking for the following:

  1. Internal IP filters
  2. Lowercase filters on medium, source, campaign, campaign content (for data cleanliness)
  3. Include hostname filters for your own store (to prevent spam data)

There are a handful of others that I also outline in my Google Analytics foundation previously linked in previous step but these are the big ones.

“Other” Traffic / Default Channel Grouping

Inside of GA > Acquisition > All Traffic > Channels, do you see a large amount of (Other) traffic? If so then this is likely traffic that is tagged with utm parameters that Google isn’t automatically bucketing into predefined channels.

You can control this within your view settings by editing or creating new channel groupings.

For example, you might want to break up:

Paid Social Prospecting vs Paid Social Retargeting or just Paid Social from Organic Social.

There is typically one rule that rules all stores – don’t leave the default settings “as is”. You can read more on the “why” this is important in my marketing attribution 101 guide.

That’s it (for now). Leave comments below if you have any questions!

If you received this guide from a friend please sign up for our email to receive more guides like this!

More Marketing & Analytics Tips

Sign up to receive our latest posts on everything from GTM to Optimization.

We respect your inbox.


Brad Redding

Brad, co-founder of Elevar, has lived in eCommerce for over 12 years. He's helped design, build, and optimize over 100 websites in his career. From new retail startups to well-known brands like Le Creuset, Signature Hardware, Rebecca Minkoff, Char-Broil and more, he specializes in data analytics and conversion optimization to help achieve business goals.

  1. Hello Brand, thank you for the great post.
    I’ve a couple of questions.
    Do you consider a good strategy to mix both google tag manager and embedded code to trigger events?
    We use Ajax requests extensively and it a bit complicated to get the data from google tag manager only.

    The second question is about the tag “Google Remarketing Tag – Checkout”.
    In your setup it uses the tag {{ecomm_prodid}} ( window.ShopifyAnalytics.meta.product.variants.0.sku ) which is not available during the checkout, so it results being undefined.
    And even if it would be available wouldn’t it consider only the first product in the cart ?
    Am I right or I missed something ?

    1. Hi Federico,

      Yes, if you’re able to push custom events from your theme to dataLayer/GTM then that is definitely helpful!

      Regarding the Checkout tag. You’re correct on both accounts..this was the one tag I noted was not working/setup as it should, I just haven’t had a chance to jump back into this to update! Good catch/thinking. I’ll try and update this one tag soon after additional testing.

Leave a Reply

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

Related Articles

Talk with Us

Please complete the form to request a demo, discuss our solutions, or to just say hi!



Some of our clients