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
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>