Max
Max

Reputation: 6258

Google Analytics Event Tracking Transition to Universal Tracking

We are currently using the "old" Google Analytics (ga.js) with custom event tracking on our site (custom HTML, no CMS, 30-40 pages).

We are using this function:

   function recordOutboundLink(link, category, action, label) {
        _gat._getTrackerByName()._trackEvent(category, action, label);
        setTimeout('document.location = "' + link.href + '"', 100);}

in the header and add it with:

   onclick="recordOutboundLink(this, '...', '...', '...');

to the elements we want to track the clicks on. (Mainly outbound Links)

I recently set up a new property and added Universal Tracking. We are receiving data, but I played around with the event code, but nothing happens. We are using both the old ga.js and analytics.js as suggested by Google not to corrupt any data. Is there an "easy" way to adapt the new Universal Tracking Code to "accept"/use our existing function without changing all the code?

Any help appreciated.

Upvotes: 0

Views: 1247

Answers (1)

Eduardo
Eduardo

Reputation: 22832

Just update your function to send to Universal Analytics as well.

function recordOutboundLink(link, category, action, label) {
  _gat._getTrackerByName()._trackEvent(category, action, label);
  ga('send', 'event', category, action, label);
  setTimeout('document.location = "' + link.href + '"', 100);
}

Upvotes: 1

Related Questions