Home > Questions and Answers > General Questions

How To Greet Visitors? (9)


06-16-2011 03:14 AM #1 shanktank (Member)
How To Greet Visitors?

LOL @ my thread name.

I wanted to ask how to grab the token from my cpvlab tracking url, so that it greets visitors from a certain placement?

My token is &keyword={placement}
The placement grabs the domain name from where the visitor clicked a Google ad.

I want the landing page to then show "Hello, visitors from [insert placement here]"

And if it doesn't find a placement token, or that a placement is iamwatchingporn.com, don't show the text at all.

How can I do this?


06-16-2011 10:27 PM #2 joshtodd ()

First of all, in CPV Lab on the Edit Campaign screen, make sure that you have the box checked for "Pass Target to Landing Page":



Next, place this code where you want the target to appear:
[PHP]<?php echo($_GET["target"]) ?>[/PHP]

Or to have it formatted with the Domain and Uppercase, place this code instead:
[PHP]<?php $target = str_replace('http://', '', str_replace('https://', '', str_replace('www.', '', $_GET["target"]))); echo(ucfirst(strpos($target,'/') !== false ? substr($target,0,strpos($target,'/')) : $target)); ?>[/PHP]

So your LP should have something like this on it:
[PHP]Hello, visitors from <?php echo($_GET["target"]) ?>[/PHP]

Also make sure to save your LP as a .php file instead of .html and you should be set.


06-17-2011 12:22 AM #3 shanktank (Member)

Is there a way to make

Code:
Hello, visitors from <?php echo($_GET["target"]) ?>
not show when it finds that a target is from a certain domain? (i.e. spy.com)


06-17-2011 12:26 AM #4 polarbacon (Moderator)

Quote Originally Posted by shanktank View Post
Is there a way to make
Code:
Hello, visitors from <?php echo($_GET["target"]) ?>
not show when it finds that a target is from a certain domain? (i.e. spy.com)
the whole line of txt or just the variable ?


06-17-2011 03:01 AM #5 shanktank (Member)

Whole line.


06-17-2011 04:47 PM #6 joshtodd ()

The variable itself won't show if there is no target. That's why I usually word it like "Hello _____ Visitors" because then if the variable is missing it won't look like a broken sentence. I don't know of a way to make the whole line disappear, but I'm not a programmer.


06-17-2011 05:05 PM #7 bbrock32 (Administrator)

Yeah can be done pretty easily :

[PHP]
<?php
$target = str_replace('http://', '', str_replace('https://', '', str_replace('www.', '', $_GET["target"])));
if($target!="spy.com")
echo "Hello, visitors from $target";
?>
[/PHP]

Change spy.com with whatever domain you want.


06-17-2011 05:52 PM #8 southbound (Member)

[PHP]if (isset($_GET["target"])) {
echo "Official $_GET["target"] Notice";
}[/PHP]


06-17-2011 06:11 PM #9 jdrmar (Member)

Just to expand a little on this: if you have multiple sites that you don't want the message to show, or maybe a different message, you could do it like this:

[PHP]$target = str_replace('http://', '', str_replace('https://', '', str_replace('www.', '', $_GET["target"])));

$no_show = array('spy.com','otherdomain.com','etc.com');
if($target != '' && !in_array($target, $no_show){
echo "Hello, visitor from $target";
}else{
echo "Hello, visitor";
//or delete the above to not show any message
}
[/PHP]


Home > Questions and Answers > General Questions