I found something interesting on the Google Code site today. In one part of it they had “How GIF Requests Are Classified”. Interesting, since that’s what this section of this series has been all about. In it they cite the following:
A GIF request is sent to the Analytics servers in the following cases and classified according to the table below. In each of these cases, the GIF request is identified by type in the utmt parameter. In addition, the type of the request also determines which data is sent to the Analytics servers. For example, transaction and item data is only sent to the Analytics servers when a purchase is made. Visitor, page, and system information is only sent when an event is recorded or when a page loads, and the user-defined value is only sent when the _setVar method is called.
They then go on to mark pages, events, transactions, and items as “interactions” and var’s as non-interactions, claiming:
Requests classified as interaction requests will impact the bounce rate calculations for your page or site. Bounce rate is referred to as a single-page visit to your site, but is strictly defined as a single interaction request during a user session. For this reason, a bounce rate for a page is also affected by ecommerce transactions and event tracking requests. This is because these features co-exist with page tracking and, when they are triggered, they result in additional interaction requests to the Analytics servers.
Man, that could have saved me a few posts, eh?
Anyhow, today we’re going to talk about the last two in that list: trans and items. These are added using _addTrans() and _addItem() functions.
_addTrans() initializes a transaction object, which stores all your transaction data (billing address, shipping charges, etc.). These are then associated with items via an order ID. Makes sense right? You can have multiple items within one transaction. Think of this as your shopping cart.
_addItem(), on the other hand, tracks information specific to each item in a shopping cart. This can be SKUs, price, quantity, etc.
Specifically, trans tracks:
- order ID – required
- affiliation or store name
- total – required
- tax
- shipping
- city
- state or province
- country
While item track:
- order ID – required
- SKU/code – required
- product name
- category or variation
- unit price – required
- quantity – required
I used an ordered list here for a reason. Each property must be listed in the correct order. If you don’t use that property then you will have to list it differently. eg. _addItem(“12345”, “46789”, “”, “”, “24.99”, “1”);
Remember, according to Google:
If a transaction contains multiple items and the SKU is not supplied for every item, a GIF request is sent only for the last item added to the transaction for which a SKU is provided. In addition, if your inventory has different items with the same SKU, and a visitor purchases both of them, you will receive data for only the most recently added. For this reason, you should make sure that each item you offer has a unique SKU.
So, what should your _addTrans and _addItem’s look like:
_gaq.push(['_addTrans', '1234', // order ID - required 'Acme Clothing', // affiliation or store name '11.99', // total - required '1.29', // tax '5', // shipping 'San Jose', // city 'California', // state or province 'USA' // country // add item might be called for every item in the shopping cart // where your ecommerce engine loops through each item in the cart and // prints out _addItem for each _gaq.push(['_addItem', '1234', // order ID - required 'DD44', // SKU/code - required 'T-Shirt', // product name 'Green Medium', // category or variation '11.99', // unit price - required '1' // quantity - required ]); _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
Remember that you’ll need a tracktrans to submit the transaction data to the analytics servers.
Associated with an ecommerce transaction is going to be the following values:
- utmtid – your OrderID
- utmtst – affiliation
- utmtto – total value for a unit
- utmttx – total tx
- utmtsp – shipping cost
- utmtci – billing city
- utmtrg – billing reigon
- utmtco – billing country
So, you set your _addTrans and _addItem, your visitor visits, visits the right pages, and those make calls through _addTrans and _addItem to Google Analytics, which then writes them into a .gif request and…
…your utm.gif should look something like the following:
Per Transaction:
https://www.google-analytics.com/__utm.gif?utmwv=4.9.2 utms=6 utmn=1684715033 utmhn=store.analysite.net utmt=tran utmtid=1304117814682 utmtst=Northern%20Warehouse utmtto=535.52 utmttx=37.52 utmtsp=29.00 utmtci=Portland utmtrg=Oregon utmtco=USA utmac=UA-9999-9 utmcc=__utma%[...] utmu=DRALAAAwE~
Per Item:
https://www.google-analytics.com/__utm.gif?utmwv=4.9.2 utms=5 utmn=1533116887 utmhn=www.analysite.net utmt=item utmtid=1304117435168 utmipc=STATIC-456 utmipn=Tea%20bags utmiva=military%20issue%2C%20Earl%20grey utmipr=53 utmiqt=4 utmac=UA-9999-9 utmcc=__utma[...] utmu=DRALAAAwE~
And there you have it. We’re done with request types! Stay tuned next week when we take a look at more juicy details of utm.gif requests and how to Really Understand Google Analytics.