Posts: 4
Registered: ‎04-17-2018

How to use header title for the event label to be sent to GA?


I am trying to track the links as shown in the screenshot (pink) and to give it the eventlabel of the corresponding Header Title (orange). How do I go about that? Thanks for any help!


I have the following extensions ready:


DOM Ready JS Code:

// jQuery listener for all 'a' Tags at the Page
jQuery(document).on('click', 'a', function(e) {
    // Variable Declaration
  var tgt = jQuery(;
  var clickURL = tgt.attr('href');
  var clickText = tgt.text().replace(/[^a-zA-Z0-9]+/g, "-");
  var clickClass = tgt.attr('class');
  var clickID = tgt.attr('id');
  var clickURLHostname = this.hostname;
  var clickURLPath = this.pathname;
  var clickElement = jQuery([0];
  var clickType;

    // Check if the clicked Link is internal or External. 
    // Please edit 'PLACEHOLDER'
  if (clickURLHostname.indexOf("") === -1) {
    clickType = "external";
  }else {
    clickType = "internal";
  // sent Tealium Event with all click Elements{
    'tealium_event' : 'link_click',
    'click_url' : clickURL,
    'click_text' : clickText,
    'click_class' : clickClass,
    'click_id' : clickID,
    'click_urlHostname' : clickURLHostname,
    'click_urlPath' : clickURLPath,
    'click_type' : clickType,
    'click_element': clickElement

 Thanks for any help! 

0 Kudos
Posts: 16
Registered: ‎04-02-2018

Re: How to use header title for the event label to be sent to GA?

[ Edited ]

Hi @chriszp,

In your link you have href links. Last portion of href link is titile. So, you can use the split function to get the last portion of the URL and pass it to the label. 

Here is the sample code you need to add.

var clickTitle = tgt[0].href.split("/")[tgt[0].href.split("/").length-1];


0 Kudos