Re: Restrict access to a landing page info

Charles_THIERY
Level 3

Restrict access to a landing page info

Hello,

I'm not an expert of Javascript coding and I would be grateful if somebody can help me to complete my script coding.

Basically, I want that a lead clicking on a email link generated with a lead.token reaches the landing page and the JS checks against his current lead.token value (if it's equal) to show the right section.

My email will generate an email link http://www.example.com?approved={{lead.versionning}}    (here lead.versionning is a number).

I have 2 section in the html called "approved" and "rejected" that I want to have display depending the following test.

<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>

<script type="text/javascript">

// Parse the URL parameter

function getParameterByName(name, url) {

   if (!url) 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, " "));

}

// Give the parameter a variable name and convert to Number for making comparison

var dynamicContent = Number (getParameterByName('approved'));

var versionning = Number ({{lead.versionning}});

// Display the righ section according the test of versionning   

$(document).ready(function() {

// Check if the URL parameter is apples

if (dynamicContent == versionning) {

$('#approved').show();

}  else {

$('#rejected').show();

});

</script>

I don't know if what I put in bold would work because not sure how to pass to lead.token within JS.

Sandford Whiteman​, you are the one who help me before, hope you can help me again.

Best Regards,

Charles

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Restrict access to a landing page info

This seems like a roundabout way of accomplishing a simple goal. Why don't you just create a Segmentation and segment the page? This has the additional advantage of completely hiding the unapproved content.