Skip to main content
Charles_THIERY
Level 2
July 13, 2017
Question

Restrict access to a landing page info

  • July 13, 2017
  • 1 reply
  • 1917 views

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 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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
Level 10
July 13, 2017

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.