Add custom dimensions to custom event and eCommerce tracking ?

1,834 views
Skip to first unread message

Lothaire Ruellan

unread,
Nov 12, 2012, 10:38:21 AM11/12/12
to google-analyti...@googlegroups.com
One of the big limitations I have encountered with GA is the fact that the data model for custom event tracking only supports 3 custom dimensions (category, action, label).
Some custom events would be more precisely described if we could add additional custom dimensions for a particular event.

Since I work in the travel vertical, let's take for example a travel website with an airfare booking engine. We could define a custom event for a "fare search", and we'd most likely would like to capture the following information:

category: air
action: search
label: New York to London
originCountry: USA
destinationCountry: United Kingdom
originAirportCode: NYC
destinationAirportCode: LON
originCityName: New York
destinationCityName: London
searchMode: One Way

etc...

Is there a way do achieve this with the new custom dimensions with analytics.js?
My understanding is that the custom dimensions in the new analytics are basically stand-alone custom dimensions that can be set at any point, but they do not integrate with '_trackEvent' - unless I am mistaken?

Similarly, I really would like to add custom dimensions to the eCommerce product and transaction tracking. For instance, it would be great if we could add the product selection path that was used to add a product to the cart, or the delivery method selected for an order (electronic delivery, physical delivery etc...). Is this going to be possible to do with analytics.js?

Lothaire

Brad Townsend

unread,
Nov 12, 2012, 5:19:08 PM11/12/12
to Lothaire Ruellan, google-analyti...@googlegroups.com
Hi Lothaire,

Depending on how you tag your page and configure the custom dimensions they can apply to a single hit, all hits on a page, a single session, or a visitor.

For your example use-case you would need to setup 7 dimensions, all "Hit" scope, then send an event hit as follows:

ga("send", "event", {
  eventCategory: "air",
  eventAction: "search",
  eventLabel: "New York to London",
  dimension1: "USA",
  dimension2: "United Kingdom", 
  dimension3: "NYC",
  dimension4: "LON",
  dimension5: "New York",
  dimension6: "London",
  dimension7: "One Way"
});

By using this syntax you'll only be sending these particular custom dimension values with the event hit. Other hits on your page (pageview, events, etc.) wouldn't include these values.

-Brad Townsend
 Google




Lothaire

--
 
 

Lothaire Ruellan

unread,
Nov 13, 2012, 11:51:32 PM11/13/12
to google-analyti...@googlegroups.com
Thanks Brad. This is fantastic. I'll get started on implementing this. Thank you. I suppose the same approach can be used for adding dimensions to eCommerce transaction.
Thanks again for the tip.

Lothaire Ruellan

unread,
Nov 14, 2012, 10:43:49 AM11/14/12
to google-analyti...@googlegroups.com
Brad, is it possible to use variables like product name and product SKU outside of an eCommerce transaction.

For instance, in the context of a travel website, I would like to have a report showing the "look to book" ratio of various airfares. 
The "look to book" would be defined as: number of times a particular route was booked / number of times a particular route was searched.

In the eCommerce tracking, I use the route name (eg: "Paris to New York") as the product name.
Can I send to GA a productName and productId attribute in my "fare search" custom event (as described in my initial post), and would I then be able to create a single custom report showing for each product (ie: route), how many times they were searched (custom event "fare search" count measure) and how many times they were purchased (product purchase unit measure).
Would this work?

Thank you.

Lothaire

Brad Townsend

unread,
Nov 14, 2012, 5:09:18 PM11/14/12
to Lothaire Ruellan, google-analyti...@googlegroups.com
Fields specific to e-commerce, like product name and SKU will be ignored if included with non e-commerce hit types. You could, however, create custom dimensions to capture product information along with your event hits.



--
 
 

Lothaire Ruellan

unread,
Nov 14, 2012, 9:02:04 PM11/14/12
to google-analyti...@googlegroups.com, Lothaire Ruellan
I see. In order to get a report where I would have side by side the number of searches (custom event) and revenue (product purchase) for a given route, would it work if I created a custom variable called "route" and populated it both when a "fare search" custom event occurred and when an eCommerce product purchase occurred (at the item level)?

Lothaire Ruellan

unread,
Jan 6, 2013, 1:44:34 PM1/6/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
Hi Brad,

I tried passing some custom dimensions with my eCommerce transaction calls, but they are not being recorded it seems. Is this the expected behavior? Do I need to make a separate tracking request to pass custom dimension values after using the eCommerce functions?

Lothaire

Matt Clarke

unread,
Jan 7, 2013, 9:05:42 AM1/7/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
I'm trying to achieve something similar to Lothaire. 

I am currently sending e-commerce tracking data using the client-side analytics.js. However, I want to send custom dimensions and metrics for things like profit, margin, supplier and manufacturer using the Measurement Protocol. Some of these data are sensitive, so I don't want them to appear in the code. 

Is it feasible to join these two sets of data together in GA in some way, or should I give up and send all e-commerce data using the Measurement Protocol instead?

The overall goal is to be able to improve on the default e-commerce analysis tools by adding product, category, manufacturer and supplier level conversion rate, revenue, profit and margin data. 

Thanks,
Matt

Edward Brocklebank

unread,
Mar 19, 2013, 2:03:26 PM3/19/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
Hey Matt,

Have a look at this presentation from slide 31 onwards:

The way he has done it (I haven't tried this...) is to read the customer ID out of the GA cookie. When he sends server side information using the Measurement Protocol, he sends this number with it and GA ties everything together.

Ed

nm

unread,
Mar 19, 2013, 2:08:47 PM3/19/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
Hi yes, you can do this.

The only issue is that the IP addresses will gets modified from sending the server side http request to GA.

Besides this, sending data to Google Analytics from multiple environments, for the same user / session, is exactly what Universal Analytics solves.

-Nick

Matt Clarke

unread,
Mar 19, 2013, 3:47:19 PM3/19/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
Hi Ed, 
Thanks for the reply. I've tried that and it works - as those are my slides! :)

Matt

Edward Brocklebank

unread,
Mar 19, 2013, 4:01:07 PM3/19/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
Haha oops :) Nice slides then!

I thought you said in your post you weren't able to get it working.

Ed

Eivind Savio

unread,
Mar 19, 2013, 6:11:31 PM3/19/13
to Edward Brocklebank, google-analyti...@googlegroups.com, Lothaire Ruellan

It didn’t work previously. It was updated a couple of weeks ago.

No it works like a charm.

 

BTW, I’ve found that if you for a transaction have a metric counter for each product (ex. persons ordered this product), the total number of persons for the transaction will be summed.

 

Example from travel industry:

3 persons ordered seating, and 2 of these persons ordered 4 meals. This is correct on the product level, but the transaction counter will tell you that this is 5 persons (since the metric is summed).

What you can do is to send a negative number for this transaction (-2), and then you will get 3 persons for the transaction and still have the correct counter for each product (3 and 2).

 

/ Eivind

--
You received this message because you are subscribed to the Google Groups "google-analytics-analyticsjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-ana...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Matt Clarke

unread,
Mar 20, 2013, 3:25:21 AM3/20/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
Sorry, you're right. It didn't work back then, and it didn't when I wrote the slides. However, as Eivind says, the GA team added support for it following the discussions here. Which is brilliant! 

Cheers,
Matt

Lothaire Ruellan

unread,
Mar 20, 2013, 11:11:02 AM3/20/13
to Matt Clarke, google-analyti...@googlegroups.com, Lothaire Ruellan
Unfortunately, it seems like custom metrics set as currency are not working when passed to GA at the item level.
Myself and another forum user have encountered the issue, apparently. It must be a bug though. Did anyone else try it and notice the problem? Custom metrics set as integer work fine indeed now, at the product level.

--
You received this message because you are subscribed to a topic in the Google Groups "google-analytics-analyticsjs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-analytics-analyticsjs/_5o3Ge7B2FY/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to google-analytics-ana...@googlegroups.com.

Edward Brocklebank

unread,
Mar 23, 2013, 11:12:44 AM3/23/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
Hi Lothaire,

I am passing currency custom metrics at the item level in the ecommerce code and they seem to be being recorded OK.

In the attached image, product cost and product margin are both custom metrics (product cost is meant to be zero in this case, it was just test data!). Gross Margin Percentage is an Integer CM.

Ed
To unsubscribe from this group and all its topics, send an email to google-analytics-analyticsjs+unsub...@googlegroups.com.

Lothaire Ruellan

unread,
Mar 25, 2013, 2:27:06 PM3/25/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
Hi Edwards,

Thanks for your message. That's interesting - are you passing the values as integer or decimals for your custom metric? I was talking with some folks at GA who pointed out that the reason my data was not coming through was because I was passing it as decimal values (eg: 450.00) and custom metrics must be integer, as per the dev documentation. 

Lothaire
Message has been deleted
Message has been deleted

Yehoshua Coren

unread,
Sep 15, 2013, 4:24:58 PM9/15/13
to google-analyti...@googlegroups.com
Gregg, 

Is this comment just a plug for your commercial product?

Yehoshua

On Friday, July 19, 2013 11:47:51 AM UTC+2, Gregg Satzinger wrote:
For an ecommerce site, the site contains lots of key areas that needs to be tracked. Like, people click on add to cart but do not put an order, tracking such information help an ecommerce site owner to analyze what is missing in tern of tracking.

p...@4starelectronics.com

unread,
Oct 8, 2013, 4:29:22 PM10/8/13
to google-analyti...@googlegroups.com, Lothaire Ruellan
How are you accomplishing this?  I am having similar difficulty as Lothaire.
Reply all
Reply to author
Forward
0 new messages