Importing Product Data using the Management API

Andrew Wales, Google Analytics Developer Relations – May 2014

This guide describes how to simplify your enhanced ecommerce implementation by importing product data using the Management API. For more information on importing product data, see the Product Data import example.


Importing product data into Google Analytics simplifies and reduces the amount of ecommerce data you need to send along with hits, like pageviews and events. A single product ID or SKU sent to Google Analytics at collection time can be joined with your imported product data to populate product dimensions and metrics in your reports.

Before You Begin

Before completing this solution guide, read:


To enable data import for product data:

  1. Create the Data Set
  2. Prepare the Product Data CSV for Upload
  3. Upload the Product Data Using the Management API
  4. Update Your Ecommerce Code to Send the Product SKU

To learn how to upload your Data Set to Google Analytics using the Web Interface, see the Enhanced Ecommerce User Guide.

Create the Data Set

The first step to importing product data is to create a Data Set for your product data and to set the schema which defines the dimensions and metrics you'd like to import.

Follow the Data Import Developer Guide to create your Data Set, select Product Data as the Data Set type and Product SKU as the Key.

Figure 1: Creating a Product Data Set.

After creating the Data Set, make note of the Custom Data Source ID, which you will use in the next step to import your product data into Google Analytics using the Management API.

Prepare the Product Data CSV for Upload

Your product data CSV must contain a header row, a column for Product SKU, and a column for each dimension and/or metric to be imported as defined by the Data Set schema.

Follow the Data Import Developer Guide to prepare your product data CSV for import, using Product SKU as the key in the first column.

Figure 2: Preparing Product Data for upload in a CSV file.

The CSV file looks like this:

12345,Triblend Shortsleeve T-Shirt,Google,Apparel,black,15.25
67890,Donut Friday Scented T-Shirt,Google,Apparel,gray,33.85
10292,Kaiser the Snake T-Shirt,Google,Apparel,green,19.10
67584,Organic Cotton Android T-Shirt,Google,Apparel,black,13.50
90876,Maps Biking T-Shirt,Google,Apparel,blue,15.65

Upload the Product Data Using the Management API

After you've created the Data Set, defined the schema, and prepared your product data for upload in a CSV, you're ready to upload your product data using the Management API.

After the product data has been uploaded, validated, and processed, Product SKUs will be joined with the uploaded product data when a match occurs on incoming hits sent to Google Analytics from your property.

Update Your Ecommerce Code to Send the Product SKU

After you've uploaded product data, update your ecommerce code to send Product SKUs with each of your hits, along with any additional data you want in your reports, like custom dimensions or metrics.

// Example of sending a transaction when joining with imported product data.
ga('create', 'UA-XXXX-Y');
ga('require', 'ec', 'ec.js'); // Load the Enhanced Ecommerce plug-in. Required.

// The product name, price, and other product data will be added to this hit
// at collection time if the value of the id field matches a Product SKU
// you've uploaded.
ga('ec:addImpression', {
  'id': '12345',              // Product ID/SKU (Key). Required.
  'list': 'Search Results',
  'position': 1,
  'dimension1': 'Member'

ga('send', 'pageview');       // Send the impression with a pageview hit.

Product IDs sent from your enhanced ecommerce implementation will now be matched to Product SKUs in your imported product Data Set, and your reports will be automatically populated with the additional product data you've uploaded.