4

Is it possible to pass more than one label in a single call of _trackEvent(category, action, label, value) so it could be used in report as a separate as a separate dimension or for filtering purposes?

My requirement is to track links (downloads) clicks for documents related with many meta-data parameters (document ID, product ID, category, language, revision etc.) and all those parameters should be available in customized reports.

Thanks in advance for help.

Marek
  • 1,688
  • 1
  • 29
  • 47

2 Answers2

3

GA is not set up to track that granular of data about any one item.

And, since GA uses gif requests to send the data, you may bump up on the limit given the amount of data you want to send.

One way of tracking all the data you want to would be to push the data into a database via an ajax request.

If you have to use GA for this, you may be able to send multiple _trackEvents for each or a grouping of the meta-data items based on the document. A setTimeout should be used so GA has time to send the events. See Can I track multiple Google Analytics events at once?

In your case you would use:

 function recordOutboundLink(link, category, action) {
    _gaq.push(['_trackEvent', 'Click', 'Download', 'Whatever']); //could be mutlipush here
    setTimeout('document.location = "' + link.href + '"', 100);
}

HTML

<a href="http://www.example.com/pdf.pdf" onClick="recordOutboundLink(this, 'Outbound Links', 'example.com');return false;">

Also, install Chrome and the Google Analytics Debugger. Look in the console (control, shift, j) for the event tracking processing.

enter image description here

If you don't see all of your events tracking there (they will be listed separately), then something is up maybe with the tracking code.

Community
  • 1
  • 1
jk.
  • 14,365
  • 4
  • 43
  • 58
  • Thank you for reply. I have one concern about the method you described. If I send _trackEvent more than one time on one link click will GA treat this as multiple clicks? How can I identify this situation on reports? – Marek Mar 09 '12 at 15:18
  • 1
    @Marek No, see [One Push, Multiple Commands](http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html#MultipleCommands) – jk. Mar 09 '12 at 15:39
  • Your solution will fit my requirements. Thank you again. – Marek Mar 12 '12 at 09:34
2

I've found in API docs that the same goal (tracking multiple key-value pairs sent in one _trackEvent request) could be achieved with custom variables:

_gaq.push(['_setCustomVar', 1, 'Items Removed', 'Yes'],
          ['_trackEvent', 'Shopping', 'Item Removal']);

The one important limitation of this approach is up to 5 maximum number of custom variables (or up to 50 extended custom variables for Premium GA Account)

Marek
  • 1,688
  • 1
  • 29
  • 47