Home > Programming, Servers & Scripts >

Exit Pop ON/OFF Script (8)


05-06-2012 06:34 PM #1 profitable ()
Exit Pop ON/OFF Script

Is there a way to turn exit pops on and off using a subid in the url? Would be a big help for using 1 lp on multiple networks.

The subid would basically tell the exit pop script whether or not to run.

on page script:
if pop=facebook then exit pop = OFF
if pop=msn then exit pop = ON
if pop=adblade then exit pop = OFF

url
siteaddy.com/?pop=facebook
siteaddy.com/?pop=msn
siteaddy.com/?pop=adblade

can that be done in php?


05-06-2012 06:38 PM #2 tap1on (Member)

yes it can

if($_GET['pop'] == "msn") //popscript here


05-07-2012 12:25 AM #3 profitable ()

Thanks tap1on, that's awesome,

How would that look for multiple subids? is there a way to do multiple without pasting the postscript in there for each one?

Non Coder Example:
if pop=msn then include pop code in a php or js file here
or
if pop=msn then run script here

This way there could be only 1 exit pop script?


05-07-2012 03:03 AM #4 zeno (Administrator)

Just use an or operator inside the if statement. E.g. if($_GET['pop'] == "msn" or $_GET['pop'] == "adblade") //insert script after here. Just insert whatever subids you want the popscript to activate into the if statement with the 'or' operator separating them. I'd be inclined to insert something like this into your page:

<?php

$pop = $_GET['pop'] //get the traffic source subid

if($pop == "msn" or $pop == "adblade"){ //if subid any of these execute the below
<script here>
</script>
}

?>


05-07-2012 06:12 AM #5 profitable ()

Ok getting really close. I can now get it to echo Hello World if pop = msn or adblade like this:

Code:
<?php

if($_GET['pop'] == "msn" or $_GET['pop'] == "adblade") //popscript here

echo '<p>Hello World</p>';


?>
but when I paste the javascript exitpop code after //postscript here it breaks and the page won't load.

Code:
<?php

if($_GET['pop'] == "msn" or $_GET['pop'] == "adblade") //popscript here

{
<script type="text/javascript" language="javascript">
var areYouReallySure = false;
var internalLink = false;
function areYouSure() {
if (!areYouReallySure && !internalLink) {
areYouReallySure = true;
location.href="#"
return "WAIT!";
}
}
window.onbeforeunload = areYouSure;
</script>
}
?>
Is there a proper way to load the javascript that i'm missing?


05-07-2012 06:29 AM #6 zeno (Administrator)

View the source of your page and see if it has spat out the script source. You might need to put echo before the <script ... part to make the PHP actually print that into the page the browser loads. PHP is server side whilst javascript is client side, so as it stands I think the PHP code doesn't actually inject the javascript code into the page that the browser loads. Hence the echo command. So:

Code:
<?php

if($_GET['pop'] == "msn" or $_GET['pop'] == "adblade") //popscript here
{
echo '<script type="text/javascript" language="javascript">
var areYouReallySure = false;
var internalLink = false;
function areYouSure() {
if (!areYouReallySure && !internalLink) {
areYouReallySure = true;
location.href="#"
return "WAIT!";
}
}
window.onbeforeunload = areYouSure;
</script>';
}
?>
Try that.


05-07-2012 04:51 PM #7 profitable ()

Big thanks Zeno and tap1on. Works perfectly.


05-08-2012 02:38 AM #8 zeno (Administrator)

Glad to hear it.


Home > Programming, Servers & Scripts >