Reply
Highlighted
Visitor
Posts: 2
Registered: ‎03-11-2016

Call utag.link() on HTML-link click

I want to trigger a Google Conversion when a user clicks on a HTML link. I achieve this with a JavaScript Extension which add an event handler on the click and then call utag.link() with data layer parameter which make Tealium call the Google Conversion. But when the HTML-Link redirects to another page it occurs that the new page loads before the request is sent (especially when Google redirects three times before the conversion is submitted).

 

I think the solution would be to prevent the execution of the link and redirect the user after the utag.link() and all consecutive events are finished. Can this be accomplished by using the callback-parameter in utag.link()?

 

Or is it better to call the conversion directly like described in the google docs (https://support.google.com/adwords/answer/6331304) without using utag.link at all?

 

Or am I completely missing something?

Reply
0 Kudos
Community Manager
Posts: 470
Registered: ‎08-26-2015

Re: Call utag.link() on HTML-link click

Hello @franzel. Have you tried using the jQuery onHandler Extension instead to track your event? Let me know!

Reply
0 Kudos
Tealium Employee
Posts: 18
Registered: ‎09-01-2015

Re: Call utag.link() on HTML-link click

Hi @franzel,

 

There are a couple of things you can try.

 

1) Mousedown vs. click

In the event handler logic, if you are executing utag.link on a click, the other logic on the page may execute before the utag.link occurs. Try replacing the 'click' logic with 'mousedown'. This may trigger the utag.link prior to the page processing the href click.

 

2) The pixel is fired but you are not seeing it

Without all the details this is a shot in the dark. If, for example, you are using Chrome and viewing the Network panel for verification of the pixel being sent, make sure the option Preserve Log checked to ensure the list remains intact when the new page loads. 

 

Let me know if either of these suggestions help.

 

Thank you, David

Contributor
Posts: 46
Registered: ‎11-15-2015

Re: Call utag.link() on HTML-link click

Hi @franzel,

 

Nevertheless, we can use jQuery event.stopPropagation() Method,  if you are executing utag.link on a click/Mousedown on the page may trigger the utag.link prior to the page processing the href click.

 

Example:

$("span").click(function(event){
    event.stopPropagation();
    alert("The span element was clicked.");
});
$("p").click(function(event){
    alert("The p element was clicked.");
});
$("div").click(function(){
    alert("The div element was clicked.");
});

 

Hope it helps out!!!