How to track clicks on anchor links? | Community
Skip to main content
Level 3
July 20, 2021
Solved

How to track clicks on anchor links?

  • July 20, 2021
  • 1 reply
  • 4472 views

Hello community!

 

How to track clicks on anchor links?

 

We have implemented tracking on a page, but we are not getting any logs for clicks on anchor links.

 

According to (Marketo Master Jedi 😀) @sanfordwhiteman, Munchkin ignores clicks by default on 'links whose destination appears to be a hash (fragment) on the current page: - a below-the-fold jump link like <a href="#section1">"...' - https://blog.teknkl.com/more-munchkin-untracked-links-part-1/

Note I was not able to find the part 2 of the above mentioned post.


Furthermore, he provides the code that should solve the problem, in the following post, using what he calls the 'the mchReDecorate technique': https://nation.marketo.com/t5/product-discussions/track-anchor-links-with-munchkin/td-p/97774

Now, I tried to implement it, but it's not working - we are still not getting any logs for clicks on anchor links.

 

Do you know how to solve this problem and can you please share the solution?

 

Or can you give further info on how to properly apply the so called mchReDecorate technique?

 

I have written to Marketo Support for further assistance, and I will make sure to update this post for future googlers if I manage to solve it via their help.

Thanks in advance for your time!

 

Best,
ernie

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Update


Now that I removed the code, and added it again it seems like something is actually happening:
<screenshot-removed>

But I am getting inconsistent results - not all anchor links are being tracked.

I'm currently in the process of finding out what works and what does not work...


The code is designed to run on DOMContentLoaded, but you’re loading it after that event fires because you’re injecting it via GTM. Therefore it’s waiting for an event that never comes.

1 reply

SanfordWhiteman
Level 10
July 20, 2021

You’d have to show the page you’re trying this on. Nothing particularly complex about the code unless you have other code deliberately calling stopImmediatePropagation(), which stops additional listeners from firing.

NestoJosaAuthor
Level 3
July 21, 2021

Here is the page where I am trying your code:

<url-to-site-removed>

The code used is from your post found here:

https://nation.marketo.com/t5/product-discussions/track-anchor-links-with-munchkin/m-p/97775/highlight/true#M60027

How did I implement it?

- Added via GTM

- The code is added when user gives consent to cookies (via "Accept all" on the cookie banner).

Thanks for the help!

NestoJosaAuthor
Level 3
July 21, 2021

Update


Now that I removed the code, and added it again it seems like something is actually happening:
<screenshot-removed>

But I am getting inconsistent results - not all anchor links are being tracked.

I'm currently in the process of finding out what works and what does not work...