Event Tracking

Showing 1-15 of 15 messages
Event Tracking lilbit 8/17/09 9:40 AM
I have a non-ecommerce site but would like track my outbound links and I'm able to to pull variables for various products, can I use event tracking for this sort of metrics? Example onclick="pageTracker._trackEvent('Products', 'Online Purchase', 'Fun Straw Cup, ', '0');

I have the onclick event in the href tag with various variables to collect including price, however, after the click on the link the page gets redirect to a page to execute another script and then goes to the destination page.

Is this method doable? Any suggestion would be greatly appreciated.

Re: Event Tracking DreamingConversions 8/18/09 12:54 AM
It should work. As soon as click happens and _trackEvent is executed, corresponding event will be recorded on GA.
Re: Event Tracking lilbit 8/18/09 5:36 AM
Thanks DreamingConversions

I think I've found the issue, onclick="pageTracker._trackEvent('Products', 'Online Purchase', 'Fun Straw Cup, ', '0');

'Fun Straw Cup, ',

After Fun Straw Cup there must be another variable that describe the product either with size or color. However, if there are no size or color that spot will be null, would this keep the event tracking from working? I'm thinking it's confused when collecting the data into analytics. What's your thoughts?
Re: Event Tracking DreamingConversions 8/18/09 7:07 AM
Hey lilbit1,

_trackEvent has only four parameters, out of which, last two are optional.
_trackEvent(category, action, optional_label, optional_value)

I see a syntax problem with your code as 'Fun Straw Cup,' contains a comma.

Correct syntax would be:

onclick="pageTracker._trackEvent('Products', 'Online Purchase', 'Fun Straw Cup', '0');"
Re: Event Tracking lilbit 8/18/09 8:50 AM
DreamingConversions thank you so much for confirming!

I kind of thought that was the problem but really needed confirmation.

Another quick question on the same subject if you don't mind. Review the following href tag

<a id="ctl00_phMainContent_rptOnline_ctl01_hlOnline1" onclick="pageTracker._trackEvent('Products', 'Online Purchase', 'Discovery Seat', '0');" href="rdr.aspx?h=Discovery+Seat&amp;f=Alpha&amp;m=0&amp;t=idndzvhhg&amp;u=http%3a%2f%2f.xyz.com%2ffs-bin%2fclick%3fid%3d%2fMwvlfm17MM%26offerid%3d123456.1234567%26type%3d2%26subid%3d0" target="_blank">Link</a>

you notice there is a bunch of other stuff to the link, will any of that prevent the event tracking from working?

Re: Event Tracking DreamingConversions 8/18/09 9:03 AM
You can mark it as a good news that everything should work with this href TAG ;)
Re: Event Tracking lilbit 8/18/09 9:17 AM
Re: Event Tracking lilbit 8/23/09 6:25 PM
Hi DreamingConversion

Just wanted to follow-up on things I've found with the above event tracking through some testing. Removing the extra comma still wouldn't work. However, I found that the single quote around the optional_value '0' is not required. Also, through testing comma's within optional_label is allowed. Sample;

onclick="pageTracker._trackEvent('Products', 'Online Purchase', 'Fun Straw Cup, Red', 0);"


onclick="pageTracker._trackEvent('Products', 'Online Purchase', 'Fun Straw Cup\, Red', 0);"

Just wanted to pass along what I've found for future use. My next challenge is how to allow decimal points in the optional_value like 19.95. When removing the decimal point it's treated as 1,995 and an even amount like 100 is treated as 100.00.

I'll post back if I can figure out what works.

Re: Event Tracking DreamingConversions 8/24/09 12:48 AM
Hi lilbit,

Your observatioins are correct. I'm sorry not to mention these things earlier.
1. Only first two parameters are required while the rest two are optional i.e. you can leave them.
2. If you are using a comma as part of your text, you have to escape it using \.
3. Last parameter 'optional_value' is an integer and, therefore, should not be written as a string.
4. Unfortunately, as mentioned above, last parameter is an integer, therefore, it is not possible to use decimal points.

Here you can learn further about Event Tracking: http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

As it seems to me that you are trying to track your e-commerce transactions. Please use Google e-commerce tracking for that purpose so that you can use decimal points too. Here you can learn further about e-commerce tracking:http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55528

Hope this helps.
Re: Event Tracking lilbit 8/24/09 5:04 AM

The site I'm trying to collect data is not an e-commerce site can I still use Google's e-commerce tracking? I just didn't think it was possible.

Re: Event Tracking DreamingConversions 8/24/09 5:41 AM
Yes, you can do it for non e-commerce websites too :)

Re: Event Tracking PPC_Guru 9/7/09 2:20 PM
I have posted this message to GA team:

Event Tracking documentation page is unclear due to these 4 common errors reading this page:

1. optional_value is an integer also-known-as "a number with 0 decimal places". This should be on BIG writing on the help page.

2. Because optional_value is a integer it does NOT need to be surrounded by quotes.

_trackEvent('category', 'action', 'optional_label', optional_value)

3. Comma, single or double quotations need to be escaped e.g.
4. When using eventTracking & a virtual pageview on the same function; double quotes need to be changed to single quotes, so that the function is correctly encapsulated :

_trackEvent("category", "action", "optional_label", optional_value)
onclick="_trackEvent('category', 'action', 'optional_label', optional_value);"

Or here is a live example:
<a href="http://www.yourdomain.com/page.htm" onclick="pageTracker._trackEvent('category', 'action', 'optional_label', optional_value); pageTracker._trackPageview('/page.htm'); ">Link which triggers event & virual pageview</a>


Re: Event Tracking lilbit 9/8/09 5:21 AM

I totally agree, it is unclear in a lot of places and with everyone's help here I managed to get it to work. Having more samples on these help pages can tremendously help someone like me. There is SO much you can do with GA and I'm only half way through.

Again thank you everyone!
Re: Event Tracking oil4lessllc 10/29/10 12:19 AM
RE: lilbit posting on 8/23/09,
  One can pass any value '100', '100.00', '123.45', etc in the javascript by putting quotes around the value as i did in this sentence.
  I did that in a program totally unrelated to GA and it works fine; can even put in signs: '-', '-12', etc.
  Seems to convert to a string and wisiwig.
Re: Event Tracking oil4lessllc 1/8/11 1:12 PM
NOT solved!
  Absolutely ZERO events captured, and no links indicated from Nov 29, with the exception of something that does NOT exist on my site, begins with "search/srpcache?ei-UTF" and is insanely long (242 characters).
  As recommended, my code has had the following since Dec1:
** At top:
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19002128-2']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
** Sample in body
 <a href="http://www.oil4lessllc.com/Kelvin.pdf" onClick="that=this;_gaq.push(['_trackEvent,'pdf','download','Kelvin',that.href]);setTimeout(function() { location.href=that.href }, 200);return false;">Kelvin connector system</a><br>
 <font face="Arial" size=3>
  <a href="http://www.oil4lessllc.com/IndustLinks.html" onClick="that=this;_gaq.push(['_trackEvent,'page','view','Links',that.href]);setTimeout(function() { location.href=that.href }, 200);return false;">Industrial Links</a><br></font>
** end
  ALSO, i _still_ get stuff recorded to the "plain" site oil4lessllc.com (NO www) despite the 301 re-direct!