AdAccRun Meta,Google and TikTok agency ad accounts
High-limit Meta agency accounts, plus Google and TikTok ad account solutions for advertisers, media buyers and agencies ready to scale.

Fire Postback On Button Click

affrabby

Grand Guru
Joined
Sep 28, 2018
Messages
494
I want to fire conversion when someone click on CTA button, I was tried Google Tag manager earlier, but that pretty complex to me. I ask chatGTP today to write code for this but that script not working properly. I dont have enough programing knowledge. Anyone can help me to figure out the issue why its not working.

Code by ChatGTP

<script>
// Retrieve the click ID from the URL parameter
function getClickIdFromUrl() {
var urlParams = new URLSearchParams(window.location.search);
return urlParams.get("clickid");
}

// Send the postback URL with the click ID when the button is clicked
function sendPostback() {
// Replace "http://your-postback-url.com" with your actual postback URL
var postbackUrl = "http://your-postback-url.com?clickid=" + getClickIdFromUrl();
var img = new Image();
img.src = postbackUrl;
img.width = 1;
img.height = 1;
document.body.appendChild(img);
}

// Add an event listener to the button to call the sendPostback function when clicked
var button = document.getElementById("your-button-id");
button.addEventListener("click", sendPostback);
</script>
 
To view the premium content in our affiliate marketing forum (including this awesome thread), you must first register and upgrade your account. Register today and become a part of our amazing community!
Top