AdWords
4.9K members online now
4.9K members online now
Use AdWords conversion tracking and reporting to measure your results. Have a question about Google Analytics? Post it here, on the Google Analytics Community!
Guide Me
star_border
Reply

How do I change my Events to Universal Analytics?

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I previously had several events tracking nicely, but upgraded to Universal Analytics early July and now my page views and bounce rates are all over the place and events are tracking zero. 

 

Can you please describe what I need to do to translate my previous event code (below) to Universal?

 

<script type="text/javascript">
function recordOutboundLink(link, category, action, opt_label, opt_value) {
_gat._getTrackerByName()._trackEvent(category, action, opt_label, opt_value);
setTimeout('document.location = "' + link.href + '"', 100);
}
</script>

 


<script type="text/javascript">
var a = document.getElementsByTagName('a');
for(i = 0; i < a.length; i++){
if (a[i].href.indexOf(location.host) == -1 && a[i].href.match(/^http:\/\//i)){
a[i].onclick = function(){_gaq.push(['_trackEvent', 'outgoing_links', this.href.replace(/^http:\/\//i, '')]);}
}
}</script>

 

 

Thanks - any help much appreciated.

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Beverley B
September 2015

Re: How do I change my Events to Universal Analytics?

Explorer ✭ ✭ ✭
# 4
Explorer ✭ ✭ ✭
Hi Beverley,

Event tracking in Universal analytics is completely different. To send an event, you need to pass the ga function the send command with the event hit type. The _gaq.push is no longer used.

For example: ga('send', 'event', 'category', 'action', 'label');
Instead of the old one _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)

Cheers,
Nouman

View solution in original post

Re: How do I change my Events to Universal Analytics?

Top Contributor
# 2
Top Contributor

Hello,

 

Here's the Event Tracking methodology explained for the users using Universal Analytics: https://developers.google.com/analytics/devguides/collection/analyticsjs/events

 

There is a dedicated Google Analytics forum. Here is the link: https://productforums.google.com/forum/#!forum/analytics

 

You might consider re-posting it over there.

 

Pankaj

Re: How do I change my Events to Universal Analytics?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thank you I've posted in the suggested forum.
Regards
Marked as Best Answer.
Solution
Accepted by topic author Beverley B
September 2015

Re: How do I change my Events to Universal Analytics?

Explorer ✭ ✭ ✭
# 4
Explorer ✭ ✭ ✭
Hi Beverley,

Event tracking in Universal analytics is completely different. To send an event, you need to pass the ga function the send command with the event hit type. The _gaq.push is no longer used.

For example: ga('send', 'event', 'category', 'action', 'label');
Instead of the old one _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)

Cheers,
Nouman

Re: How do I change my Events to Universal Analytics?

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Thanks for your help. Very useful :-)

Re: How do I change my Events to Universal Analytics?

Explorer ✭ ✭ ✭
# 6
Explorer ✭ ✭ ✭
Pleasure to be helpful Smiley Happy