Skip to main content

Triggering Zapier/External API on Button Click

Simply add the following snippet onto your thankwebpage youand page.bind it to a button click event.

The following script will mergecapture thedata queryfrom argumentHandL with the handl utmUTM grabber cookies and trigger your webhook with all the data.gathered data when the button is clicked.

This is especially useful,useful for sending data seamlessly when prospectsusers redirectedengage fromby webinarclicking optina signupspecific wherebutton theon optinyour data appended to the thank you page URL as query arguments.page.

Don't forget to change the Zapier URL below with your own Webhook URL.

<script>
var qvars = {};
window.location.href.replace(/[?&]+([^=&]+document.getElementById("your-button-id")=([^&]*)/gi,.addEventListener("click", function(m,key,value)) {qvars[key] = value;});
qvars = Object.assign(handl_utm,qvars)
setTimeout(function(){
    var data = newHandL.getAll(); URLSearchParams(qvars).toString()//this console.log(data)will have all the tracking data
    data.customParam1 = 'value1'; //add your own
    data.customParam2 = 'value2';
    
    var xmlHttpjson = JSON.stringify(data);
    var xhr = new XMLHttpRequest();
    xmlHttp.xhr.open( "GET"POST", 'https://hooks.zapier.your-url.com/hooks/catch/5711357/b5af0ju/?'+data,endpoint', falsetrue);
    xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
    // false for synchronous request
	xmlHttp.xhr.send( null )json);
}, 1000));
</script>