Link Click href element (class, id) sometime capture the wrong element


#1

I experience this weird issue with the Link Click event, where sometime the href element class and id is capturing the wrong information.

For example I have the following href:

<a href=/somelinks.html id=banner1 class=top_banner

When I click on that link, sometime the unstruct_event field shows elementClass and elementID value other than ‘top_banner’ and ‘banner1’, which belong to other unrelated href link. Sometime both values are blank.

What could possibly cause this?

Thanks!


#2

Could you share a HTML example of the page and your tracker initialisation to recreate?


#3

this my pageview tag on GTM:

> <!-- Snowplow starts plowing -->
> <script type="text/javascript">
> ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
> p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
> };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
> n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.1/sp.js","snowplow"));
> 
> window.snowplow('newTracker', 'cf', '//sp.xxxxx.com', { // Initialise a tracker
>   appId: 'MyShop',
>   discoverRootDomain: true,
>   forceUnsecureTracker: true,
>   stateStorageStrategy: "localStorage",
>   contexts: {
>     webPage: true,
>     performanceTiming: false,
>     gaCookies: false,
>     geolocation: false
>   }
> });
> 
> window.snowplow('setUserId', {{User ID}});
> window.snowplow('enableActivityTracking', 30, 10);
> window.snowplow('trackPageView');
> window.snowplow('enableLinkClickTracking');
> </script>
> <!-- Snowplow stops plowing -->

This is the html part where I want to track the link click:

> <!DOCTYPE html>
> <html lang="id" xml:lang="id" style="height: 100%;" xmlns="http://www.w3.org/1999/xhtml">
>    <head>
>       <title></title>
> 	  <!-- GTM Snippet here -->
>    </head>
>    <body style="top: 0px; padding-top: 60px; position: relative; min-height: 100%;">
>       <!-- GTM Snippet here -->
> 	  <!-- some codes -->
> 	  
>       <div class="container">
>          <div id="product_recommendation_aws_scarab_container">
>             <div class="span12" style="margin-left:0px !important;width:1190px !important">
>                <div class="main-section" id="product_recommendation_aws">
>                   <div class="card no-pad">
>                      <div class="swiper-container main-swiper swiper-container-horizontal" id="prodcut_recommendation_aws">
>                         <div class="swiper-wrapper" style="transform: translate3d(-1190px, 0px, 0px); transition-duration: 0ms;">
>                            <div class="swiper-slide swp-prd no-translate  swiper-slide-duplicate" style="width: 198.33px;" data-swiper-slide-index="2">
>                               
> 							  <!-- this part below is the href I'm trying to track, class dm_sp_user_reco -->
> 							  <a class="dm_sp_user_reco" id="3" href="https://www.example.com/product/ProductDetailAction/getProductDetail.do?prdNo=24197443" data-scarabitem="3">
>                                  <p class="prd-img">			<img width="170" height="170" class="prdRecAwsLazy" style="background-repeat: no-repeat; background-position: center center; display: inline;" onerror="this.src=CommonImage.getNoimgUrl(_SSL_IMG_URL_, 170);" alt="Apel Fuji China 1 kg" data-original="https://image.example.com/g/1/9/7/4/4/3/24197443_B.jpg">	</p>
>                                  <p class="prd-title notranslate">Apel Fuji China 1 kg</p>
>                                  <p class="prd-price-b notranslate"></p>
>                                  <p class="prd-price notranslate"><strong> Rp28.500</strong></p>
>                               </a>
>                            </div>
>                         </div>
>                      </div>
>                   </div>
>                </div>
>             </div>
>          </div>
>       </div>
>    </body>
> </html>

I hope this provide enough info.

Thanks!


#4

It looks like you’re currently using version 2.5.1 of the Javascript tracker. This release is a few years old so I’d first upgrade to the latest version of the Javascript tracker (2.9.2 as of writing but I believe @mhadam is working on 2.9.3 at the moment ) and see if you can recreate the same issue.