Shopify: Fix your Google Analytics Product Performance Reports

The Problem: By default Shopify includes product variant details in the product’s name when it sends e-commerce data to Google Analytics, . If you sell clothing ,or shoes, or other products with color and size variants, then your Product Performance Report becomes too granular.

ga-productperformance-productname

How Shopify data shows up by default in Google Analytics. Notice that the various “Trillium Parka” variants are ungrouped because the size and color information is in the product name. This makes it difficult to see aggregate data for all variants of this product.

This is a bug, because there already exists a “Product Variant” field in Analytics, and it is already being properly populated.

The Solution:
Google Analytics Custom Data Import

The solution to this problem is to overwrite the Shopify data using the Custom Data Import tool.

Step 1: Export your Product Data

First we need to export all our product data – you can use a similar technique to generating your own custom Google Shopping Product Feeds to build a CSV export file.

a. Create a new Collection Template

Call the new collection template csv-ga-product-feed and paste the following code:

{% layout none %}{% paginate collection.products by 1000 %}ga:productSku,ga:productName,ga:productVariant{% for product in collection.products %}{% for variant in product.variants %}
{{ variant.sku }},{{ product.title | replace: ',','' }},{{variant.title | replace: ',',''}}{% endfor %}{% endfor %}{% endpaginate %}

(also available on GitHub here)

b. Create a new Collection based on your csv-ga-product-feed Template

Select the products you want to include in this feed (probably all your products). These will be the products whose values will be overwritten in Google Analytics. Call your collection “Google Analytics Product Data Import” or something similar and save it.

c. Download your Product Feed

  • View your new collection in your store (eg: store.myshopify.com/collections/google-analytics-product-data-import)
  • View source in your browser and save as HTML
  • Rename the file with a CSV extension (eg: google-analytics-product-data-import.csv)

Step 2: Setup and Import the data into Google Analytics

IMPORTANT WARNING! I highly recommend you duplicate or backup your Google Analytics view and do a trial run before working with your live data. Once you upload this new data and overwrite there is no UNDO!

a. Setup the Data Feed

  • Go to Google Analytics > Admin > Account > Property > Data Import
  • Click the red “+ NEW DATA SET” button
  • Select “Product Data”
  • Give your Data Import a name: “Product Name Override”
  • Select the Google Analytics Views you want this import to affect
  • Setup your Data Set Schema: Product SKU is the mandatory key, but select Product and Product Variant as the additional fields.
  • Overwrite Hit Data: Choose Yes (but read my warning above)
  • Click Save and Done

b. Upload your data feed

  • Click on “manage uploads” beside your new Data Feed definition
  • Click the blue UPLOAD button
  • Choose your CSV file and click UPLOAD again
  • And now wait for the upload an update to be complete

Step 3: Verify your new data

The data upload will only affect data from this date forward. So your old data will unfortunately not be fixed. But your future data will be nice and clean.

You will need to wait at least a day before you start seeing the new data coming in. If you add new product SKUs to your store, you will also need to regenerate and reupload a new file in order for the new product data to be fixed.

13 Comments

  1. Okay – 24 hours after implementation, all data prior to the implementation is now gone. It was still there as of last night, but woke up this morning and the view i tested this on was totally wiped except for data post-implementation. Is that expected?

    Like

    Reply

      1. Yes.

        So – the original view with product variants, which I duplicated off of, is totally fine. However, the duplicate view I tested this with is now missing all historical data prior to the product data implementation.

        I implemented exactly step by step around 12PM on the 8th. The feed hooked up and I was able to see the new product names flowing in correctly around 2PM, with historical data still intact. I checked one more time before i signed off around 630pm and all was well. Checked the next morning and that’s when the historical data dropped off. Not sure what the solution is here.

        Like

    1. Do you know if your upload is scheduled to recur every day? Or is it a one-time upload? (In my implementation, I did it as a one-time upload. I wonder *if* you are using a recurring upload, that maybe the recurring upload failed and uploaded blank data that wiped everything out?? Just guessing here…)

      Like

      Reply

      1. Double checked and it was uploaded as a one-time upload. I just created a new test dupe, anything I should try changing before I re-run on the new test?

        Like

      2. I think I may have figured out what happened. What do you make of it, Alex?

        https://www.en.advertisercommunity.com/t5/Google-Analytics-Filters/No-data-for-new-view/td-p/486147

        “To turn User ID on or off, Admin > Property > tracking ID > User ID.

        HOWEVER, it is probably NOT what you think. You do not just turn it on…
        “User-ID enables the association of one or more sessions (and the activity within those sessions) with a unique and persistent ID that you send to Analytics.” i.e. you need to implement javascript code on your website to send the user id with the page hit. Without doing that, all new views you create in your account will be empty, as Ilya discovered.”

        Like

      3. 1) I think it’s very good to know (I didn’t) that turning on User Id tracking will mess up your views if you didn’t actually implement user tracking.

        2) If this is what happened to you, then I’m happy my code didn’t mess up your account! 🙂

        Like

  2. I was able to get this working, my import was 10,000 rows. Followed instructions exactly as described and only had one hiccup – if the product name contains a quote, the CSV import throws an error. I replaced the quotes with ‘, and it worked.

    Like

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s