affrabby
Grand Guru
- Joined
- Sep 28, 2018
- Messages
- 488
How it Works:
- Hyperlink Update: Every <a> link on the page has an event listener added. When clicked, the default action is prevented and the script fires a postback and then redirects.
- Error Handling: In case of an error during the postback, the user will still be redirected to the intended link.
Key Points:
- CTA URL: The CTA link has been set to https://google.com/.
- Postback Handling: The firePostbackAndRedirect function now uses this CTA link for redirection.
- Link Update: Every hyperlink (<a> tag) will have its click event intercepted to fire the postback and then redirect to https://google.com/.
Code:
// Function to get query parameters from the URL
function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}
// Get the clickid from the URL
const clickid = getQueryParam('clickid');
// Function to fire the postback and redirect to CTA link
function firePostbackAndRedirect() {
const ctaUrl = 'https://google.com/';
if (clickid) {
fetch(`https://xxxxx.maxconvtrk.com/conv?clid=${clickid}`)
.then(response => {
// Postback successful, redirect to CTA link
window.location.href = ctaUrl;
})
.catch(error => {
console.error('Error firing