简体   繁体   中英

How to configure Google Tag Manager to track link clicks on the same page

I have a single page website set up with internal links - I want to track these links and all other clicks that occur on my page, for example:

website.com/#link-to-here

Then further down I have the following HTML:

<div id="link-to-here"></div>

So when clicked the viewport changes to view that particular id but stays on the same page.

I am trying to set up the auto event listener - which seems to work but only tracks the one link I have to another page on the website(the rest is on the same page).

I have set up Analytics Universal, tag manager and all of my page views are working and in the live view.

I followed various tutorials and in Tag Manager I currently have 3 tags set up:

  • Universal Analytics with a firing rule for 'all pages' - no conditions

  • Link Click Listener with 2 firing rules 'all clicks' which has a condition of {{event}} equals gtm.click then the condition 'all pages' with the condition {{url}} matches RegEx .*

  • UA event on internal links with the firing rule 'Internal Link Click' with again 2 conditions {{event}} contains gtm.linkClick and also {{url}} contains spectrospective (this is part of the URL). I figured i wouldn't be sure if their would be www. or not so this might eliminate any variances because the URL will always contain spectrospective - although this is probably where I went wrong.

Your link click listener only needs to fire with the rule "all pages".

If this event is only for tracking internal link clicks, then perhaps just change the {{url}} part to {{hostname}} (the hostname is a part of the url), so that you don't need to check the entire url. This probably won't happen, but you could get a link like http://www.example.com/spectrospective , in which case the name "spectrospective" is in the url, but it's not an internal link, and your event would fire.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM