Skro
One single dashboard to manage all your ads. API Integrations for Meta, TikTok, Google, Taboola, Outbrain, Sedo, Tonic, System1, Bodis, Clickbank...

Guide Fire any CTA Clicks as Conversions

Partners.House

affrabby

Grand Guru
Joined
Sep 28, 2018
Messages
487
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:​

  1. CTA URL: The CTA link has been set to https://google.com/.
  2. Postback Handling: The firePostbackAndRedirect function now uses this CTA link for redirection.
  3. Link Update: Every hyperlink (<a> tag) will have its click event intercepted to fire the postback and then redirect to https://google.com/.
This script will ensure that whenever a user clicks any link on the page, the postback is fired and they are redirected 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
 
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