Home > POP / PPV / Redirect >

Dynamic keywords insertion formatter (15)


10-30-2011 01:17 PM #1 dpol (Member)
Dynamic keywords insertion formatter

Hey guys,

I have written a script that formats domain names on dynamic keywords insertion.
I am not php programmer, so some of you can say that my code is not optimal, but for some of you it will save time

It formats domain strings in the following cases:
CONVERT:
.domain.
.domain.c
.domain.co
domain.c
domain.co
domain.com/.../.../...
.domain.com/.../.../...
INTO:
domain.com

ALSO SUPPORTS:
net, info, org, gov domains

USAGE (prosper202 example):

Code:
<?php $keyword = $_GET['t202kw']; if ($_GET['OVKEY']) { $keyword = $_GET['OVKEY']; } include ('formatter.php'); echo fix_target($keyword);
?>
The script file is attached.
Enjoy and report bugs.


11-14-2011 02:24 PM #2 alex_b (Member)

Thanks for the share, dpol!

So far I have only targeted URLs but now I'm working on a campaign that includes keywords as well, how do you go about this when implementing DKI in your headline? I mean, as a really lame example, "dear walmart coupon visitor" sounds really retarded.

Do you separate keyword campaigns from URL campaigns? Or do you have some php magic with a logic like "if no .com found, use alternate headline" or something? I'm a real php noob so would appreciate some guidance.


11-19-2011 05:31 AM #3 virgin (Member)

can you please post cpvlab example


11-19-2011 07:25 PM #4 liane (Member)

Quote Originally Posted by alex_b View Post
Thanks for the share, dpol!

So far I have only targeted URLs but now I'm working on a campaign that includes keywords as well, how do you go about this when implementing DKI in your headline? I mean, as a really lame example, "dear walmart coupon visitor" sounds really retarded.

Do you separate keyword campaigns from URL campaigns? Or do you have some php magic with a logic like "if no .com found, use alternate headline" or something? I'm a real php noob so would appreciate some guidance.
How about, "Looking for KEYWORD?"

Or...do you mean the campaign is mixed?


11-20-2011 12:10 AM #5 alex_b (Member)

Quote Originally Posted by liane View Post
How about, "Looking for KEYWORD?"

Or...do you mean the campaign is mixed?
I mean, I have both URLs and keywords as targets (same niche) for this campaign. So if the target is a URL, I want the headline to be "Welcome [URL] visitor", for example, and if it's a keyword the headline should be different (like the example you suggested). Is there a simple way to do this?


11-20-2011 09:39 AM #6 tijn (Moderator)

Shank just send me this link

http://ctrtard.com/affiliate-marketi...o-root-domain/

Heres the function:L

[PHP]<?php
function trim_url_to_root_domain($target) {
/** Trim Url to Root Domain
* by ctrtard.com 8/1/2011
*
* This function is mainly useful for PPV. You can pass it a URL (target) and it
* will trim it down to the root domain. Unlike most other examples I've found,
* It handles subdomains and squirrely, or malformed URLs like "//something.domain.com"
* The result is a nice looking domain for dynamic keyword insertion into your
* landing pages.
*
* Usage:
* echo trim_url_to_root_domain("http://mytarget.com");
* or
* echo ucfirst (trim_url_to_root_domain("http://mytarget.com")); // uppercase first letter
*
*/
// trim http, https, and //
$target = str_replace("http:", "", $target);
$target = str_replace("https:", "", $target);
$target = str_replace("//", "", $target);

// check for dots
$dots = substr_count($target, '.');
if ($dots > 1) { // if there are more than 1 dots, we need to remove subdomain
$first_dot = strpos ($target, ".");
$target = substr($target, $first_dot+1, strlen($target));
}

// find the last slash, this should be the slash just before directory info
$last_slash = strripos($target, "/");
if ($last_slash > 0 ) {
$target = substr($target, 0, $last_slash);
}

// find last slash one more time, to handle targets like /domain.com
$last_slash = strripos($target, "/");
if ($last_slash !== FALSE ) {
$target = substr($target, 1, strlen($target));
}

// normalize target so it's all lower case
$target = strtolower($target);

return $target;
}
?>
[/PHP]


11-21-2011 08:02 PM #7 jakz (Member)

I am FAR from a coding dude, but I hacked away at the php code posted by CTRtard for extracting root domains and the code from @dpol's "formatter.php" script herein to fix partial domains.

The following code (which I just paste at the bottom of my lander instead of a seperate script) will trim any subdomain, trim any subdirectories (no matter how longtail it is), fix partial domains (e.g. Amazon.c), and capitalize the first letter of the domain name (optional).

Not sure if anybody else needed code to do all this shit together, but it helps me, so I figured I would share.

Props to dpol and CTRtard!

Place this code in Head section to snag the keyword (this gets a Prosper202 keyword)
[PHP]<?php $target = $_GET['t202kw'];?>[/PHP]Place either of these code strings where you want to call the keyword in the Body: (e.g. Welcome <? echo ucfirst (fix_target($target));?> Shoppers! )

This will capitalize the first letter of the domain
[PHP]<? echo ucfirst (fix_target($target));?>[/PHP]or

this will NOT capitalize the first letter of the domain
[PHP]<? echo (fix_target($target));?>[/PHP]Place the code below at the bottom of your landing page and make sure you name the page with a .php extension.
[PHP]<?php

function fix_target($target)
{


// trim http, https, and //
$target = str_replace("http:", "", $target);
$target = str_replace("https:", "", $target);
$target = str_replace("//", "", $target);

// check for dots
$dots = substr_count($target, '.');
if ($dots > 1) { // if there are more than 1 dots, we need to remove subdomain
$first_dot = strpos ($target, ".");
$target = substr($target, $first_dot+1, strlen($target));
}

while(1){
if (substr_count($target, '.com') != 1)
{
// replace .co with .com
if (substr_count($target, '.co') == 1)
{
$target = str_replace(".co", ".com", $target);
break;
}

// replace .c with .com
if (substr_count($target, '.c') == 1)
{
$target = str_replace(".c", ".com", $target);
break;
}

}

if (substr_count($target, '.net') != 1)
{
// replace .ne with .net
if (substr_count($target, '.ne') == 1)
{
$target = str_replace(".ne", ".net", $target);
break;
}

// replace .n with .net
if (substr_count($target, '.n') == 1)
{
$target = str_replace(".n", ".net", $target);
break;
}

}

if (substr_count($target, '.gov') != 1)
{
// replace .go with .gov
if (substr_count($target, '.go') == 1)
{
$target = str_replace(".go", ".gov", $target);
break;
}

// replace .g with .gov
if (substr_count($target, '.g') == 1)
{
$target = str_replace(".g", ".gov", $target);
break;
}

}

if (substr_count($target, '.org') != 1)
{
// replace .or with .org
if (substr_count($target, '.or') == 1)
{
$target = str_replace(".or", ".org", $target);
break;
}

// replace .o with .org
if (substr_count($target, '.o') == 1)
{
$target = str_replace(".o", ".org", $target);
break;
}

}

if (substr_count($target, '.info') != 1)
{
// replace .inf with .info
if (substr_count($target, '.inf') == 1)
{
$target = str_replace(".inf", ".info", $target);
break;
}

// replace .in with .info
if (substr_count($target, '.in') == 1)
{
$target = str_replace(".in", ".info", $target);
break;
}

// replace .i with .info
if (substr_count($target, '.i') == 1)
{
$target = str_replace(".i", ".info", $target);
break;
}

}
break;
}

if (substr(strrev($target), 1, 1) == '.')
{
$target = $target . 'com';
}

// find domain
$pos = stripos($target, '/');
if ($pos !== false)
{
$target = $target = substr_replace($target,"",$pos);
}


// find the last slash, this should be the slash just before directory info
$last_slash = strripos($target, "/");
if ($last_slash > 0 ) {
$target = substr($target, 0, $last_slash);
}

// find last slash one more time, to handle targets like /domain.com
$last_slash = strripos($target, "/");
if ($last_slash !== FALSE ) {
$target = substr($target, 1, strlen($target));
}

// normalize target so it's all lower case
$target = strtolower($target);

return $target;
}
?>[/PHP]Jakz


11-22-2011 12:20 AM #8 alex_b (Member)

@jakz and Tijn: Thanks guys, I've already come that far (i.e. combined ctrtards and dpol's script) but I still don't know how to display an alternative headline in the case of using keywords. Maybe I'm just not expressing myself correctly, so I'll give an example:

Let's say I target a) URL "walmart.com" and b) keyword "super awesome walmart coupons". The headline shall be "Welcome [DKI SCRIPT] Visitor!"

Now with the above script, for option a (URL walmart.com), the headline will be this: "Welcome Walmart.com Visitor!" and for option b (keyword "super awesome walmart coupons") it will be "Welcome super awesome walmart coupons Visitor!", which sounds totally stupid.

That's why I'd like to tweak the script in a way that it recognizes if the target is a URL or keyword, and showing alternative headlines depending on that.

So if the target is a URL, the script shall use the standard "Welcome [URL] Visitor!". However, if it's a keyword, it shall use another headline like "Looking for [Keyword]?".

Is this possible to do?


11-23-2011 09:20 PM #9 jakz (Member)

@alex_b

You can use either one of these (whatever your preference is). Just place either one at the top of the function.

This code simply checks to see if there is a "." in the keyword. If there is a ".", it's most likely a domain name and not a text keyword string. However, if your keyword is something like, "/bonerpills/checkout.html", you either need to shorten your keyword or add these individual keyword values to the exclusion section of the php script I am pasting below.

With this code, if the keyword is not a domain name it will return nothing. So, "Welcome {KEYWORD} Shoppers!" becomes, "Welcome Shoppers!"
[PHP]
// check to see if keyword is a domain
$non_domain = substr_count($target, '.');
if ($non_domain < 1) // if there is not a dot in the keyword
return; //terminates function
}
else //continues function
[/PHP]With this code, if the keyword is not a domain name it will return your arbitrary text. So, "Welcome {KEYWORD} Shoppers!" becomes, "Welcome Internet Shoppers!" (or whatever you put after "echo")
[PHP]
// check to see if keyword is a domain
$non_domain = substr_count($target, '.');
if ($non_domain < 1) // if there is not a dot in the keyword
{echo 'Internet';
return; //terminates function
}
else //continues function
[/PHP]Hope that helps.

Jakz


11-26-2011 06:21 AM #10 alex_b (Member)

Quote Originally Posted by jakz View Post
[PHP]
// check to see if keyword is a domain
$non_domain = substr_count($target, '.');
if ($non_domain < 1) // if there is not a dot in the keyword
{echo 'Internet';
return; //terminates function
}
else //continues function
[/PHP]
That's what I was looking for, thanks!

However, it still doesn't seem to work the way I want it to. I feel like I'm almost there.

My original headline is "Welcome [URL] Visitor" and in case of a keyword, I want it to be "Looking for [keyword]?" instead.

This is what I got so far, but it returns "Welcome 0 Visitor" (instead of "Looking for [keyword]?")

[PHP]
// check to see if keyword is a domain
$non_domain = substr_count($target, '.');
if ($non_domain < 1) // if there is not a dot in the keyword
{echo 'Looking for '+ non_domain +'?';
return; //terminates function
}
else //continues function
[/PHP]


03-20-2012 05:44 PM #11 miked3 (Member)

Thanks guys! Exactly what I was looking for.

Is there a way to test it? I can see when I load my pop no value is returned, which is good in my case since my pop will just say "Congrats Visitor!" But is there a way to see if its working with passed kws so I know I set it up right?


03-20-2012 08:47 PM #12 iwanturcoin (Member)

Quote Originally Posted by alex_b View Post
That's what I was looking for, thanks!

However, it still doesn't seem to work the way I want it to. I feel like I'm almost there.

My original headline is "Welcome [URL] Visitor" and in case of a keyword, I want it to be "Looking for [keyword]?" instead.

This is what I got so far, but it returns "Welcome 0 Visitor" (instead of "Looking for [keyword]?")

[PHP]
// check to see if keyword is a domain
$non_domain = substr_count($target, '.');
if ($non_domain < 1) // if there is not a dot in the keyword
{echo 'Looking for '+ non_domain +'?';
return; //terminates function
}
else //continues function
[/PHP]
I know this is a bit old but why not just have ur URL's and keyword in seperate campaigns and have 2 LP's? problem solved. I always have my KW's as a seperate target group...


04-23-2014 02:37 AM #13 sabhssabhs (Member)

How can I test that this works when the pop loads?
Someone has asked this earlier but there was no reply.

Hope someone can help


04-23-2014 11:02 AM #14 zeno (Administrator)

Best bet for testing live is probably to install whatever adware loads the pops, or disable popup blocking and visit whatever sites you are running on if they are not pops from e.g. TV/LI, and then see what happens.

You could run a test campaign at low budget bidding on a very specific URL and just visit that to trigger the pops.

On the other hand, the script appears to GET OVKEY, which I assume is how the network passes the particular keyword triggered, and then splices it to give the domain. So you could just load your lander and add ?OVKEY=.domain.com/something/ or similar to the URL to test that it gets correctly converted to domain.com which you can echo in the lander using <?php echo $keyword; ?>


04-23-2014 11:23 AM #15 caurmen (Administrator)

The simplest way will be to follow exactly the same URL that you would paste into your traffic source, but replace the keyword token with "TEST".

If you see "Welcome TEST visitor" on your popup, it's working!


Home > POP / PPV / Redirect >