27
INTERNAL: Google Confidential and Proprietary Enhanced Ecommerce Tracking Abraham, E. Demas

Enhanced ecommerce tracking

Embed Size (px)

Citation preview

Page 1: Enhanced ecommerce tracking

INTERNAL: Google Confidential and Proprietary

Enhanced Ecommerce Tracking

Abraham, E. Demas

Page 2: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

The enhanced ecommerce plug-in for analytics.js enables the measurement of user interactions with products on ecommerce websites across the user's shopping experience, including: product impressions, product clicks, viewing product details, adding a product to a shopping cart, initiating the checkout process, transactions, and refunds.

Page 3: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Data Types and Actions

There are multiple types of ecommerce data you can send using analytics.js: impression data, product data, promotion data, and action data.

Page 4: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Data Types and Actions - Impression Data

VALUE TYPE REQUIRED DESCRIPTION

id String Yes* The product ID or SKU (e.g. P67890). *Either this field or name must be set.

name String Yes* The name of the product (e.g. Android T-Shirt). *Either this field or id must be set.

list String No The list or collection to which the product belongs (e.g. Search Results)

brand String No The brand associated with the product (e.g. Google).

category String No The category to which the product belongs (e.g. Apparel). Use / as a delimiter to specify

up to 5-levels of hierarchy (e.g. Apparel/Mens/T-Shirts).

variant String No The variant of the product (e.g. Black).

position Number No The product's position in a list or collection (e.g. 2).

price Currency No The price of a product (e.g. 29.20).

Represents information about a product that has been viewed. It is referred to as an impressionFieldObject and contains the following values: E.g. Search Results

Page 5: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Data Types and Actions - Product DataProduct data represents individual products that were viewed, added to the shopping cart, etc. It is referred to as a productFieldObject and contains the following values:

VALUE TYPE REQUIRED DESCRIPTION

id String Yes* The product ID or SKU (e.g. P67890). *Either this field or name must be set.

name String Yes* The name of the product (e.g. Android T-Shirt). *Either this field or id must be set.

brand String No The brand associated with the product (e.g. Google).

category String No The category to which the product belongs (e.g. Apparel). Use / as a delimiter to specify up to 5-levels of

hierarchy (e.g. Apparel/Mens/T-Shirts).

variant String No The variant of the product (e.g. Black).

price Currency No The price of a product (e.g. 29.20).

quantity Number No The quantity of a product (e.g. 2).

coupon String No The coupon code associated with a product (e.g. SUMMER_SALE13).

position Number No The product's position in a list or collection (e.g. 2).

Page 6: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Data Types and Actions - Promotion Data

Represents information about a promotion that has been viewed. It is referred to a promoFieldObject and contains the following values:

VALUE TYPE REQUIRED DESCRIPTION

id String Yes* The promotion ID (e.g. PROMO_1234). *Either this field or name must be set.

name String Yes* The name of the promotion (e.g. Summer Sale). *Either this field or id must be set.

creative String No The creative associated with the promotion (e.g. summer_banner2).

position String No The position of the creative (e.g. banner_slot_1).

Page 7: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Data Types and Actions - Action Data

Represents information about an ecommerce related action that has taken place. It is referred to as an actionFieldObject and contains the following values:

VALUE TYPE REQUIRED DESCRIPTION

id String Yes* The transaction ID (e.g. T1234). *Required if the action type is purchase or refund.

affiliation String No The store or affiliation from which this transaction occurred (e.g. Google Store).

revenue Currency No Specifies the total revenue or grand total associated with the transaction (e.g. 11.99). This value may include

shipping, tax costs, or other adjustments to total revenue that you want to include as part of your revenue

calculations. Note: if revenue is not set, its value will be automatically calculated using the product quantity and

price fields of all products in the same hit.

Page 8: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Data Types and Actions - Action Data

tax Currency No The total tax associated with the transaction.

shipping Currency No The shipping cost associated with the transaction.

coupon String No The transaction coupon redeemed with the transaction.

list String No The list that the associated products belong to. Optional on click or detail actions.

step Number No A number representing a step in the checkout process. Optional on checkout actions.

option String No Additional field for checkout and checkout_option actions that can describe option information on the checkout page, like

selected payment method.

Page 9: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Product and Promotion ActionsDid you notice? Something missing?

Actions specify how to interpret product and promotion data that you send to Google Analytics

Impression Actions? No need! It’s an impression, so make a good first impression.

Page 10: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

ACTION DESCRIPTION

click A click on a product or product link for one or more products.

detail A view of product details.

add Adding one or more products to a shopping cart.

remove Remove one or more products from a shopping cart.

checkout Initiating the checkout process for one or more products.

checkout_option Sending the option value for a given checkout step.

purchase The sale of one or more products.

refund The refund of one or more products.

promo_click A click on an internal promotion.

Below are the various actions that can be performed on product and promotion data:

Page 11: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation

Page 12: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring a Product Impression

In this example, a user first views the product in a list of search results. To measure this product impression, use the ec:addImpression command and provide the product details in an impressionFieldObject:

Page 13: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring a Product Impression

ga('create', 'UA-XXXXX-Y');ga('require', 'ec'); // Load enhanced ecommerce plugin

ga('ec:addImpression', { 'id': 'P12345', // Product details are provided in an impressionFieldObject. 'name': 'Android Warhol T-Shirt', 'category': 'Apparel/T-Shirts', 'brand': 'Google', 'variant': 'black', 'list': 'Search Results', 'position': 1 // 'position' indicates the product position in the list.});

ga('ec:addImpression', { 'id': 'P67890', 'name': 'YouTube Organic T-Shirt', 'type': 'view', 'category': 'Apparel/T-Shirts', 'brand': 'YouTube', 'variant': 'gray', 'list': 'Search Results', 'position': 2});

ga('send', 'pageview');

} addImpression: This is a result set of multiple products, therefore should be in a for loop

Page 14: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring a Product Click

Next, a user expresses interest in this particular product by clicking on the product listing to view more details.To measure that product click, use ec:addProduct and ec:setAction

Page 15: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring a Product Click

// Called when a link to a product is clicked.

function onProductClick() {

ga('ec:addProduct', {

'id': 'P12345',

'name': 'Android Warhol T-Shirt',

'category': 'Apparel',

'brand': 'Google',

'variant': 'black',

'position': 1

});

ga('ec:setAction', 'click', {list: 'Search Results'});

// Send click with an event, then send user to product page.

ga('send', 'event', 'UX', 'click', 'Results', {

hitCallback: function() {

document.location = '/product_details?id=P12345';

}

});

}

The product link could then be implemented like this:

<a href="/next-page.html" onclick="onProductClick(); return !ga.loaded;">T-Shirt</a>

Page 16: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring a Product Details View

After clicking on the product listing, a user views the product details page.

To measure this product details view, use ec:addProduct and ec:setAction to specify a detail action:

Page 17: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring a Product Details View

ga('create', 'UA-XXXXX-Y');

ga('require', 'ec');

ga('ec:addProduct', {

'id': 'P12345',

'name': 'Android Warhol T-Shirt',

'category': 'Apparel',

'brand': 'Google',

'variant': 'black'

});

ga('ec:setAction', 'detail');

ga('send', 'pageview'); // Send product details view with the initial pageview.

Page 18: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring an Addition or Removal from Cart

The user expresses intent to buy the item by adding it to a shopping cart.

To measure the addition or removal of a product from a shopping cart, use ec:addProduct

and set the type add or remove:

Page 19: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring an Addition or Removal from Cart

// Called when a product is added to a shopping cart.

function addToCart(product) {

ga('ec:addProduct', {

'id': product.id,

'name': product.name,

'category': product.category,

'brand': product.brand,

'variant': product.variant,

'price': product.price,

'quantity': product.qty

});

ga('ec:setAction', 'add'); // for removal use remove

ga('send', 'event', 'UX', 'click', 'add to cart'); // Send data using an event.

}

Page 20: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring Checkout Process

Now the user is ready to begin the checkout process, which in this example includes two steps, each on separate

pages:

1. Add payment details (payment.html).

2. Add shipping details (shipping.html).

Page 21: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring Checkout Process

First, make sure you’ve properly configured a checkout funnel from within Google analytics under ecommerce

settings.

Page 22: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

ga('create', 'UA-XXXXX-Y');

ga('require', 'ec');

function checkout(cart) {

for(var i = 0; i < cart.length; i++) {

var product = cart[i];

ga('ec:addProduct', {

'id': product.id,

'name': product.name,

'category': product.category,

'brand': product.brand,

'variant': product.variant,

'price': product.price,

'quantity': product.qty

});

}

}

ga('ec:setAction','checkout', {

'step': 1, // A value of 1 indicates this action is first checkout step.

'option': 'Visa' // Used to specify additional info about a checkout stage, e.g. payment method.

});

ga('send', 'pageview'); // Pageview for payment.html

Implementation: Measuring Checkout Process: Step 1 - Payment

Page 23: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

ga('create', 'UA-XXXXX-Y');

ga('require', 'ec');

function checkout(cart) {

for(var i = 0; i < cart.length; i++) {

var product = cart[i];

ga('ec:addProduct', {

'id': product.id,

'name': product.name,

'category': product.category,

'brand': product.brand,

'variant': product.variant,

'price': product.price,

'quantity': product.qty

});

}

}

ga('ec:setAction','checkout', {'step': 2});

ga('send', 'pageview'); // Pageview for shipping.html

Implementation: Measuring Checkout Process: Step 2 - Shipping

Page 24: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring Checkout Process: Step 2 - Shipping - Post selection of shipping Information

In case we don’t have additional information about the shipping option selected when the initial pageview is sent so this will be handled separately using the ec:setAction to indicate a checkout_option.

// Called when user has completed shipping options.

function onShippingComplete(stepNumber, shippingOption) {

ga('ec:setAction', 'checkout_option', {

'step': stepNumber,

'option': shippingOption

});

ga('send', 'event', 'Checkout', 'Option', {

hitCallback: function() {

// Advance to next page.

}

});

<a href="/next-page.html" onclick="onShippingComplete

(2, 'FedEx'); return !ga.loaded;">Continue</a>

Page 25: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring a Transaction

Lastly, the user completes the checkout process and submits their purchase.

To measure the sale of one or more products, use ec:addProduct to add each product, then ec:setAction to specify a

purchase. Transaction level information like total revenue, tax, etc. can be specified via an actionFieldObject. For

example:

Page 26: Enhanced ecommerce tracking

Enhanced Ecommerce - Web Tracking (analytics.js)

Implementation: Measuring a Transaction ga('create', 'UA-XXXXX-Y');

ga('require', 'ec');

ga('set', '&cu', 'EUR'); // Optional: Set tracker currency to Euros

ga('ec:addProduct', {

'id': 'P12345',

'name': 'Android Warhol T-Shirt',

'category': 'Apparel',

'brand': 'Google',

'variant': 'black',

'price': '29.20',

'quantity': 1

});

// Transaction level information is provided via an actionFieldObject.

ga('ec:setAction', 'purchase', {

'id': 'T12345',

'affiliation': 'Google Store - Online',

'revenue': '37.39',

'tax': '2.85',

'shipping': '5.34',

'coupon': 'SUMMER2013' // User added a coupon at checkout.

});

ga('send', 'pageview'); // Send transaction data with initial pageview.