Treating AJAX call as a click

Gold Contributor
Gold Contributor

I have a page for a "Join" process. The actual code on the page is out of my reach, so I need to work with what I know/see happens to trigger Tealium. It's basically a page that uses AJAX calls to swap out sections of the page without actually clicking to another page. I'm trying to track which page of the process any given user is on. 

 

Right now, I implemented a jquery extension to fire when a particular div comes into view. This works great for the initial hit, but then, since it's already in view, the extension never gets hit again as I click through the form and the variable never gets updated.

 

Is there any way to register when the AJAX happens and register it as a click to call the extension.

1 REPLY 1

Treating AJAX call as a click

Employee Emeritus

@gelerind,

 

Ideally, you would want to hardcode a utag.link or utag.view call directly in the a success of your AJAX responses.  However, since the code is out of your reach then this is not a option for you.

 

One solution may be to use a jQuery onHandler Extension, select a certain element you want to trigger off of say a "mousedown" event of a "Next" button.

 

Another solution, would be to use a custom JS extension and attached an event listener to the ajaxComplete event.  From there, you can check each request to see if it is the correct AJAX response you want to trigger your utag.link / utag.view event.

jQuery(document).on('ajaxComplete', function (a,b,c) {

  // Check a, b and/or c
  if (a.url === 'http://www.foo.com/?quickview=true') {
// Fire Tealium utag.link({ event_type : "next step" });
}
});
Public