• Welcome to affLIFT!
    We are happy you have decided to check out our awesome affiliate marketing forum. Register your account today to join our amazing community!
  • Get traffic that converts! In case you work with nutra, sweepstakes, dating or gambling offers - itโ€™s a must have! Apply promocode AFFLIFT to get a 5% bonus.
    Join ClickAdilla now!

Fire Postback On Button Click

RollerAds

affrabby

Super Contributor
Joined
Sep 28, 2018
Messages
394
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