← Back to the Start Page

Additional setup is required for funnels hosted on SamCart due to the fact that SamCart does not natively pass URL terms from page-to-page. In order for sales to be properly recorded, the appropriate URL term must appear on the SamCart checkout page.

Following is sample code you may alter and use on each page in your funnel to make sure the URL parameter containing the ad ID is passed on to the checkout page. (The following exmplefies passing two different URL parameters should it be required.)

<script type = "text/javascript" >
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 test_flag = getParameterByName('test_flag');
var testvar1 = getParameterByName('urlparam1');
var testvar2 = getParameterByName('urlparam2');
var bottle1_link = 'http://example.com/1bottle?urlparam1=' + testvar1 + '&urlparam2=' + testvar2;
var bottle3_link = 'http://example.com/3bottle?urlparam1=' + testvar1 + '&urlparam2=' + testvar2;
var bottle6_link = 'http://example.com/6bottle?urlparam1=' + testvar1 + '&urlparam2=' + testvar2;
$(".1bottle").attr("href", bottle1_link);
$(".6bottles").attr("href", bottle6_link);
$(".3bottles").attr("href", bottle3_link);
console.log(test_flag); 
</script>

<aside> 💡 IMPORTANT: It is crucial that this functionality is implemented on every step of your funnel from the landing page to the checkout page.

</aside>

For example, if the landing page URL is: www.triedandtruemedia.com/?ad_id=12345 then the resulting code implemented on each page would be:

<script type = "text/javascript" >
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 test_flag = getParameterByName('test_flag');
var urladid = getParameterByName('ad_id');
var bottle1_link = 'http://example.com/1bottle?ad_id=' + urladid;
var bottle3_link = 'http://example.com/3bottle?ad_id=' + urladid;
var bottle6_link = 'http://example.com/6bottle?ad_id=' + urladid;
$(".1bottle").attr("href", bottle1_link);
$(".6bottles").attr("href", bottle6_link);
$(".3bottles").attr("href", bottle3_link);
console.log(test_flag); 
</script>

After implementing this script, please test that the desired URL parameter is passed from the landing page through to the checkout page.