Append UTMs upon DOM change with HandL UTM Grabber

UTM attribution overview

This guide explains Append UTMs upon DOM change with HandL UTM Grabber. It helps you capture UTM source, medium, campaign, term, content, click IDs, referrer, and landing page data and keep the marketing context needed for accurate reporting across forms, bookings, signups, and sales.

Here is an example of snippet you can use to append UTMs upon a DOM change. This requires advance coding skills.

setTimeout(function(){ 

var target = document.querySelector('#storepoint-results')
var observer = new MutationObserver(function(mutations) {
	console.log(jQuery(target).find('.storepoint-onlinestore').length)
  if ( jQuery(target).find('.storepoint-onlinestore').length > 0 ){
  	var a = jQuery(target).find('.storepoint-onlinestore')
  	var target_url = a.attr('href')
  	var merged = jQuery.extend( {}, handl_utm, getSearchParams(target_url) )
  	var src = target_url.split("?")[0];
  	if ( !jQuery.isEmptyObject(merged) ){
    	var final_target = src + "?" + jQuery.param(merged)
    }
    a.attr('href', final_target)
  }
});
var config = { attributes: true, childList: true, characterData: true };
observer.observe(target, config);

 }, 500);

Revision #1
Created 15 May 2021 02:55:50 by Leman
Updated 18 May 2026 14:54:54 by Leman