Home > Paid Traffic Sources > POP / PPV / Redirect

Remove www and . and / from Targets (15)


09-05-2012 01:16 AM #1 profitable ()
Remove www and . and / from Targets

I've been digging around for this in the forums and can't seem to find any solution.

When bidding on PPV urls I'd like to be able to remove everything but the domain name

Example:
www.walmart.com
ww.walmart.com/?=
w.walmart.com/shop
walmart.c

would all show on the landing page as just: Walmart

Anyone have a script that can do this?


09-05-2012 01:24 AM #2 aabdelfataha (Member)

That would be great if someone can share something like this cus its really tedious to create a separate landing page for each target specially when you have a lot of targets this means a ton of work.


09-05-2012 01:38 AM #3 jimcrim (Member)

Ask and ye shall receive:

Code:
<?php
$target1 = $_GET['keyword'];  // Replace keyword with whatever variable you are using i.e. kw / t202kw / KEYWORD
$target2 = substr($target1, 0, strpos("$target1.", ".")); // removes everything after the "."
$target = ucwords(strtolower($target2)); // CAPS the first letter i.e. changes apple to Apple.
?>
To call this in your lander simply place the following code wherever you want to display it:
Code:
<?php echo $target?>
BAM!

Oh, damn did Maynzie copyright the Bam thing here? Oh well, let him sue me, LOL.


09-05-2012 01:47 AM #4 zeno (Administrator)

I'm confused - are you passing the target to the lander, but then wanting some manipulation of that passed url to just extract the domain name, so that you can use it in a broad sense for lots of different domains? If that's the case you should be able to do something with preg_match, I'll have a search for a bit. It can be quite complicated to have it deal with URLs in so many different iterations, TLDs etc.


09-05-2012 01:54 AM #5 jimcrim (Member)

I think he just wants to be able to dynamically put the name of the domain only onto his lander text somewhere. IE walmart.com would read Walmart in his lander. That's what the script I posted will do for him.


09-05-2012 01:54 AM #6 aabdelfataha (Member)

I love you jimcrim


09-05-2012 02:02 AM #7 zeno (Administrator)

Quote Originally Posted by jimcrim View Post
I think he just wants to be able to dynamically put the name of the domain only onto his lander text somewhere. IE walmart.com would read Walmart in his lander. That's what the script I posted will do for him.
Sweet, added to my script archives! Much simpler than I anticipated code wise ;D


09-05-2012 02:36 AM #8 hummer (Member)

Hey Jim, I think your code won't work if he uses a subdomain. A regex here might be a necessary evil.

Something like:

[PHP]<?php
$target1 = $_GET['keyword'];
$target = ucfirst(preg_replace("/^(w*\.)*(.+?)\..*/i", "$2", $target1));
?>
[/PHP]


09-05-2012 03:46 AM #9 profitable ()

Ok yes, just to confirm the code pasted by jimcrim did not quite do the trick. (thanks tho)

The code hummer posted works perfectly.

So the winning combo is

Put this at the top of your page

Code:
<?php
$target1 = $_GET['keyword'];
$target  = ucfirst(preg_replace("/^(w*\.)*(.+?)\..*/i", "$2", $target1));
?>
Insert the target on your page using

Code:
<?php echo $keyword?>

For CPV Lab:
Code:
<?php
$target1 = $_GET['target];
$target  = ucfirst(preg_replace("/^(w*\.)*(.+?)\..*/i", "$2", $target1));
?>
Insert the target on your page using

Code:
<?php echo $target?>
For P202

Code:
<?php
$target1 = $_GET['t202kw'];
$target  = ucfirst(preg_replace("/^(w*\.)*(.+?)\..*/i", "$2", $target1));
?>
Insert the target on your page using

Code:
<?php echo $t202kw?>


09-05-2012 07:03 AM #10 maynzie (Moderator)

Yo Jim, I believe its BOOM

Sick thread here, that will help ALOT with conversions on PPV from experience, thanks Profitable!


09-05-2012 12:17 PM #11 jimcrim (Member)

LOL Maynzie, good to know! I'll be sure to stay away from Boom and stick to ripping off Emeril catch phrases, HA.


09-05-2012 03:00 PM #12 zealous (Member)

Quote Originally Posted by profitable View Post
Ok yes, just to confirm the code pasted by jimcrim did not quite do the trick. (thanks tho)

The code hummer posted works perfectly.

So the winning combo is

Put this at the top of your page

Code:
<?php
$target1 = $_GET['keyword'];
$target  = ucfirst(preg_replace("/^(w*\.)*(.+?)\..*/i", "$2", $target1));
?>
Insert the target on your page using

Code:
<?php echo $keyword?>

For CPV Lab:
Code:
<?php
$target1 = $_GET['target];
$target  = ucfirst(preg_replace("/^(w*\.)*(.+?)\..*/i", "$2", $target1));
?>
Insert the target on your page using

Code:
<?php echo $target?>
For P202

Code:
<?php
$target1 = $_GET['t202kw'];
$target  = ucfirst(preg_replace("/^(w*\.)*(.+?)\..*/i", "$2", $target1));
?>
Insert the target on your page using

Code:
<?php echo $t202kw?>
Awesome...

One thing though. It prints subdomain and not parent domain.

e.g. "?t202kw=blah.justinbieber.com" prints "Blah"

Any fixes guys?


09-05-2012 05:04 PM #13 hummer (Member)

This is specific to the example he had. For you it'll be something like:

[PHP]
$otherdomains = "|blah\.";
$target = ucfirst(preg_replace("/^(w*\.$otherdomains)*(.+?)\..*/i", "$2", $target1));
[/PHP]

if you wan tot add another subdomain like for example for dreamy.justinbieber.com, just add |dreamy\. to $otherdomains
[PHP]
$otherdomains = "|blah\.|dreamy\.";
$target = ucfirst(preg_replace("/^(w*\.$otherdomains)*(.+?)\..*/i", "$2", $target1));
[/PHP]

Yes I know, it's messy.


09-05-2012 06:16 PM #14 zealous (Member)

Quote Originally Posted by hummer View Post
This is specific to the example he had. For you it'll be something like:

[PHP]
$otherdomains = "|blah\.";
$target = ucfirst(preg_replace("/^(w*\.$otherdomains)*(.+?)\..*/i", "$2", $target1));
[/PHP]

if you wan tot add another subdomain like for example for dreamy.justinbieber.com, just add |dreamy\. to $otherdomains
[PHP]
$otherdomains = "|blah\.|dreamy\.";
$target = ucfirst(preg_replace("/^(w*\.$otherdomains)*(.+?)\..*/i", "$2", $target1));
[/PHP]

Yes I know, it's messy.
Messy works! Thanks dude!


09-06-2012 03:47 PM #15 jimcrim (Member)

This may be a little cleaner and I don't think you have to continue to add subdomains to the string:

[PHP]<?php
$target1 = $_GET['keyword']; // Replace keyword with whatever variable you are using i.e. kw / t202kw / KEYWORD


$test = substr_count($target1, '.');
if($test == 2)
{ $pat = '/\.([^\"]*?)\./';
preg_match($pat, $target1, $t2);
$target3 = $t2[1];}else{
$target2 = $target1;
$target3 = substr($target2, 0, strpos("$target2.", "."));
}$target = ucwords(strtolower($target3));
?>

<?php echo $target?>[/PHP]


Home > Paid Traffic Sources > POP / PPV / Redirect