James Bachini

Passing Through Landing Page Variables

This was inspired by another post which is well worth a read at:

So many traffic sources provide you with tags such as {keyword} {countrycode} {device} etc.

You can add these variables to your url so it would look something like:

Then in the code to your landing page you can access these variables. I’ll put examples in PHP and Javascript but any web based language should provide this feature.


$mykeyword = $_GET[‘kw’]; // sets variable
echo $mykeyword; // prints variable


// You need this function in the code first
function getGets() {
fullUrl = decodeURIComponent(document.location);
if (fullUrl.indexOf(‘?’) > -1) {
uSplit = fullUrl.split(‘?’);
get = new Object;
if (uSplit[1].indexOf(‘&’) > -1) {
multiSplit = uSplit[1].split(‘&’);
for (i = 0; i < multiSplit.length; ++i) {
if (multiSplit[i].indexOf(‘=’) > -1) {
varSplit = multiSplit[i].split(‘=’);
get[varSplit[0]] = varSplit[1];
} else {
if (uSplit[1].indexOf(‘=’) > -1) {
varSplit = uSplit[1].split(‘=’);
get[varSplit[0]] = varSplit[1];
return get;
return false;

get = getGets(); // sets all variables
document.write(get.kw); // prints variable

Usage & Some Ideas

Once you have this data in the landing page you can use it actually on the landing page itself i.e.
Login now to see pics of Ukrainian Babes
Speed up your iPhone 4S and don’t buy apple products in future!

You can also pass variables through to the CPA network or Tracking system to optimise campaigns i.e.
$outlink = ‘http://www.neverblue.com/?affid=123&subid1=’.$mykeyword

You could take this a stage further and split traffic depending on variables and send it to different offers or landing pages.
if ($keyword == ‘football’) { $outfile = … }

You could display different landing pages for different site IDs to suit traffic sources with a broad range of publishers.
if (siteid == 43834) { display(girlyLP); } else { display(guysLP); }

You can also pass through your own variables. So if a traffic source doesn’t allow exit pops just upload the link with &blockpops = 1 then in the javascript code put:
if (!get.blockpops) {
window.onbeforeunload = exitPopCode;
// this will save you having multiple landing pages for different traffic sources depending on their rules.

Well that is just a basic overview of what you can do with landing page variables. Check what your traffic sources provide and what you can add to the links and see if you can use that data to improve your campaigns.

Update 15th Dec 2015

Here are some really simple examples in PHP to get you started if the above doesn’t make sense.

Copy the following 3 lines into a php file and save it as mypage.php

echo $_GET[‘c1’];

Load it on to your server and then type this into a browser: http://www.myserver.com/mypage.php?c1=HelloWorld

If it works the web page should just display HelloWorld.

Now try changing it to a link with the following code:

<a href=”http://neverblue.com/affid=123&subid=<?php echo $_GET[‘subid’]; ?>”>Click Here</a>

Try this http://www.myserver.com/mypage.php?subid=testad1

This will add the following text “testad1” to the subid for the link.

So basically whatever you want to pass through as mypage.php?firstpart=secondpart gets placed into a variable which you can access in PHP.
$myvariable = $_GET[‘firstpart’];
//this sets myvariable to “secondpart”

I’ve uploaded a really simple javascript example which you can download and test by adding a c1 var. So open it up in your local browser and add ?c1=hi to the end of the file. You can also view the source to see how it works:

You can either use this on your local computer or upload it to your server with something like:

So with php you send the variable out with:
echo $_GET[‘c1’];
and with javascript you send it out with:

But don’t forget you need the get.gets function in the javascript code first.

Hopefully this helps give a better understanding of how to pass variables through a landing page.

Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.