Streaming live at 10am (PST)

Google Analytics event tracking for external links

Hello, does anyone know what custom code to use to push notifications to google analytics every time an external link is clicked on my site?

I tried the code below (which doesn’t work) and as I have no coding background it isn’t really a surprise.

< script >

ga(‘create’, ‘UA-111279467-1’, ‘auto’);
ga(‘require’, ‘linkTracker’);
ga(‘send’, ‘pageview’);

< /script >

< script async src="/path/to/link-tracker-plugin.js">

function handleOutboundLinkClicks(event) {
ga(‘send’, ‘event’, {
eventCategory: ‘Outbound Link’,
eventAction: ‘click’,
transport: ‘beacon’

< /script >

Any help would be much appreciated!

Hi @indiaserlin, thanks for the post.

First, I would signup for Google Tag Manager and setup your tracking to use Google Tag Manage code: (also see

And add code to your HEAD of the site using the quickstart guide:

Here is how to add code to the HEAD:

Then, drag and embed widget on to the page, just under the Body tag and paste the code that goes in the body there:

After those things are set, then you can enable Google Event Tracking.

I would probably start with getting Google Tag Manager installed first, then move on to getting the tracking events created.

1 Like

This topic was automatically closed after 60 days. New replies are no longer allowed.