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.

3 Comments

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