Create a Tracking Redirect

When using 3rd party pixel trackers or link generators, you may need to send users through multiple domains that may or may not be under your control. This can cause the SegMetrics first-party pixel to lose track of a user if they're redirected and end up on a domain that is different than the original domain.

The script below can be used to allow SegMetrics to track users through every step of the process.

NOTE: You only need to use this redirection script if the final destination domain is Different than the original one. If the domain is the same, you don't need to use this.

Example:

In this case, you need to use the script:
example-landingpage.com > linktester.com > example.com
In this case, you DO NOT need to use the script:
example.com > linktester.com > example.com
In this case, you DO NOT need to use the script:
lp.example.com > linktester.com > example.com

Installing The Redirect Script

  1. Copy the Redirect Script below, and save it to your computer as seg-redirect.html
  2. In the file, replace YOUR_SEGMETRICS_PIXEL with your SegMetrics Pixel.
  3. Upload the html file to your FINAL domain.
    In the example above, we would upload the file to it to https://example.com/seg-redirect.html
  4. From your landing page, change the button or link to point to the redirection URL (in step 3), and add the redirection target to the end of the URL as a ?to= query string.
    In the example above, we would link to to https://example.com/seg-redirect.html?to=linktester.com

Redirect Script

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Redirecting</title>


    YOUR_SEGMETRICS_PIXEL


    <script>
        // 2. If we have a URL, go to the page, otherwise go back
        function getParameterByName(name, url = window.location.href) { name = name.replace(/[\[\]]/g, '\\$&'); var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url); if (!results){ return null; } if (!results[2]){ return ''; } return decodeURIComponent(results[2].replace(/\+/g, ' '));}
        var url = getParameterByName('to'); if(url){ setTimeout(function(){ window.location = url; }, 1000); } else{ window.history.back(); }
    </script>
    <style>#container{ height: 100vh;display: flex;align-items: center;justify-content: center;}</style>
</head>
<body><div id="container"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin:auto;display:block;" width="241px" height="241px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"> <circle cx="50" cy="50" r="0" fill="none" stroke="#788287" stroke-width="2"> <animate attributeName="r" repeatCount="indefinite" dur="1.7857142857142856s" values="0;18" keyTimes="0;1" keySplines="0 0.2 0.8 1" calcMode="spline" begin="-0.8928571428571428s"></animate> <animate attributeName="opacity" repeatCount="indefinite" dur="1.7857142857142856s" values="1;0" keyTimes="0;1" keySplines="0.2 0 0.8 1" calcMode="spline" begin="-0.8928571428571428s"></animate> </circle> <circle cx="50" cy="50" r="0" fill="none" stroke="#838f91" stroke-width="2"> <animate attributeName="r" repeatCount="indefinite" dur="1.7857142857142856s" values="0;18" keyTimes="0;1" keySplines="0 0.2 0.8 1" calcMode="spline"></animate> <animate attributeName="opacity" repeatCount="indefinite" dur="1.7857142857142856s" values="1;0" keyTimes="0;1" keySplines="0.2 0 0.8 1" calcMode="spline"></animate> </circle> </svg></div></body>
</html>

Still need help? Contact Us Contact Us