Mobile app version of vmapp.org
Login or Join
Angela700

: How to count offsite link clicks with Google Tag Manager I'm trying to count clicks on links leaving my site. For example, I have to count clicks on this link http://portal.adp.com/public/index.htm

@Angela700

Posted in: #GoogleTagManager

I'm trying to count clicks on links leaving my site. For example, I have to count clicks on this link portal.adp.com/public/index.htm and I'm working from documentation at Tag Manager Help > Google Analytics Events

Step 3 under Clicks on Links doesn't match the actual user interface in Google Tag Manager.

3. For each link, add a Google Analytics event tracking tag and set the
firing condition to the ‘Buy Clicks’ trigger configured above. For example:

a. Tag: Google Analytics
b. Triggers: Click
a. Name: Buy Clicks
c. Tag Name: UA - Event - Buy Link
d. Tag type: Universal Analytics
e. Track Type: Event
a. Category: Nav
b. Action: Select
c. Label: Buy


I'm hoping someone here can clarify for me what the next step is and also review the Enable when condition in my trigger below (3rd screenshot).

This is where I'm stuck in step 3 - creating a new tag and part b setting the trigger for clicks. I don't see any trigger setting option in the following dialog.



From the previous steps 1 and 2, I have the following tag and trigger.

Tag



Trigger

Potential problem: setting my site as referrer may be incorrect. My idea was to capture events where my site refers a link offsite. What should this be?


And, of course, the Tag Manager is already installed on my site.

<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-WC9CXW"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-WC9CXW');</script>
<!-- End Google Tag Manager -->


Finally, Google Analytics Help > Track outbound links provides a workaround that requires adding another script to my site and altering the HTML. I understand Tag Manager works in such a way that allows you to avoid altering site or app content. I would like to not use the workaround if possible as I will be tracking many offsite links.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sherry384

The easiest way to track outgoing link clicking is by making a variable of type Custom JavaScript. Make sure that you have the two built in variables Click URL and Page Hostname enabled. In the JS variable you can then compare these two.

Basically my script returns true or false by checking:

{{Click URL}}.indexOf({{Page Hostname}}) !== -1

{{Click URL}} == ""

typeof {{Click URL}} == 'undefined'

{{Click URL}}.indexOf('javascript:')

You can then use that variale in the trigger. Enable the trigger on any page with Page URL matches REGEX .* and set the fire when the JavaScript variable equals false.

You need to change the tag though. Currently you are just sending another pageview. What works better is setting it to type Event and then set the Event Category to Outgoing Link and the Label to {{Click URL}} That way you can easily check all the differrent URLs that are being clicked on.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme