AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4.3K members online now
4.3K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Outbound Link Script from Google not working

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I have followed the instructions on how to track outbound links. My GA tracking script is updated to the Analytics.js one, and then I have added the special script below, and I have the onclick additions made to my links like so, onclick="trackOutboundLink('http://www.example.com'); return false;" . So as far as i can tell it should be working, but I am still unable to track the outbound links from my website. Anyone have any idea what I could be doing wrong?

 

<script>
var trackOutboundLink = function(url) {
   ga('send', 'event', 'outbound', 'click', url, {'hitCallback':
     function () {
     document.location = url;
     }
   });

}
</script>

 

Thanks,

Justin

2 Expert replyverified_user

Re: Outbound Link Script from Google not working

Top Contributor
# 2
Top Contributor
Hi Justin,

This code should be working. You can check the events recorded under Behaviour -> Events.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Outbound Link Script from Google not working

Participant ✭ ✭ ✭
# 3
Participant ✭ ✭ ✭
Hi Wenlu,

As Justin stated, the code seems alright and you should be able to reach your oubound links under Behaviour > Events.

As part of installation guide, Google recomend that you install the script inside the <head></head> of the site. Although this shouldn't be a problem in most of the cases, sometimes depending on how the page is coded, you can gave some conflicts if the scripts is outside the recommended area.

Hope this helps.

Leandro Martinez | Basta1Click

Re: Outbound Link Script from Google not working

Top Contributor
# 4
Top Contributor
Hi Wenlu C,

The code you are using should be fine (make sure you are using straight quotes and not smart quotes). When you believe the event fires, please check either your real-time reports (not as reliable) or in the developer console Network tab, or with GA Debugger. If everything is working, then you should be seeing hits right away. Don't check in your standard reports yet as data needs around 24 hours to be processed, so you won't see anything right away in your Behaviour reports.

Hope this helps.
Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

Re: Outbound Link Script from Google not working

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Thank you everyone for your quick responses. I do see the traffic now under Behavior > Events. My problem was I was looking in the "Live View" on our website. Which is still the real issue, seeing just a general "Outbound" traffic does not help us. To give a bit more information we have sponsorship ads on the site and we need to see how many clicks they are getting individually, like you would see for other usual links on the site. But with this route it seems they are all just lumped into a general "Outbound" category. Does anyone know a way to make this more specific so we can see specific outbound clicks?

Thanks,
Justin

Re: Outbound Link Script from Google not working

Top Contributor
# 6
Top Contributor
Hi Justin,

Are you tracking these ads through other means including campaign tagging? This would seem like the best way to track these types of links, rather than outbound clicks. However, if you do choose to track via outbounds, then you could define an event naming strategy using specific categories, actions, and labels. You would just need to modify your code a bit. Since you are using on-page code, you would likely need to create another function to track just the ads where you change the event parameters accordingly. Otherwise using the same function to track ads would apply to all your outbound links, whether they are ad related or not.

Hope this helps.
Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

Re: Outbound Link Script from Google not working

[ Edited ]
Top Contributor
# 7
Top Contributor

Hi Justin,

 

You example code is sending the outbound link to Google Analytics as the event label.
onclick="trackOutboundLink('http://www.example.com');

 

http://www.example.com appears in GA as the event label and you can see the number of recorded events with that label. Just click "Event Label" in event overview to see this data.

 

Hope this helps.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital