This entry was posted on Monday, January 7th, 2008 at 8:54 am and is filed under NUDE. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
NUDE: Create Dynamic Landing Pages In 15 Minutes Or Less
This is the second installment in our semvironment NUDE series where we expose some of the best pay per click secrets ever! This series will be posted roughly every 2 to 4 weeks…so watch out for the naked secrets of the super successful in pay per click advertising!
If you missed the introductory installment, you can find it here.
___________________________________________
This secret will rock your world - it does not need great copy to hype it up because the results will scream success!
*Note 3/31/08 - I changed the first ucwords in the dynamic code to htmlentities for security purposes…I recommend you use htmlentities as shown in this blog post.
Without further ado, here is your quick 4 step guide to making a dynamic landing page with PHP in 15 minutes or less:
1. Open your landing page in your favorite editor and make sure it is saved as php OR html.

Copy and paste this line to your .htaccess file if you are going to use an html (or htm) landing page:
AddType application/x-httpd-php .htm .html
Now you can run php scripts in your htm(l) files.
2. Copy and Paste the following code into your landing page’s Title and content. Put your original content (the word or phrase you are replacing) in the string “Your Original Info Here”:
<?php
if ($_GET['kw'])
{echo htmlentities($_GET['kw']);}
else
{echo ucwords(”Your Original Info Here”);}
?>
For example, I want to replace the Title on the semvironment landing page so I would use this code for my Title:
The title would display the original content if somebody landed on the page without querying a keyword:

And if somebody came to our page from a specific keyword in the destination url, our Title would look like this:

This is the code I would use for one of our original content questions or headlines:
<p>Are You Looking For
<php?
if ($_GET['kw'])
{echo htmlentities($_GET['kw']);}
else
{echo ucwords(”High Quality PPC Management”);}
?>
?</p>
This question would be displayed if somebody landed on the page without querying a keyword:
Are You Looking For High Quality PPC Management?
And this question would be displayed after somebody clicked on our ad from the query “PPC Management Services”:
Are You Looking For PPC Management Services?
Using ucwords in the code will capitalize the first letter of every word in the search query or string…, you can simply remove ucwords and the corresponding parenthesis () if you don’t want to have the first letter capitalized on each word - your code would look like this:
<?php
if ($_GET['kw'])
{echo $_GET['kw'];}
else
{echo “your original info here”;}
?>
This is particularly useful if you are using it in a paragraph of regular text. You can format this so your searcher’s query can be bold or italicized or underlined, making it appear more relevant and useful to the user.
3. Save, Upload, and Test your landing page.
To test it, simply type in your landing page url -
www.yoursite.com/yourlandingpage.php?kw=your+search+query
Pretty freaking sweet, huh?
4. Now go to any ad platform and simply enter this in your destination url on your ads:
www.yoursite.com/yourlandingpage.php?kw={keyword}
Example -
My landing page is already edited using the steps listed above…so I went to AdWords to play with the Quality Score on a highly irrelevant search query. Please excuse or have fun with my mild sense of humor…
I started a new campaign and a new adgroup using the keyword homestar poopsmith.
The destination url (our company name is now semvironment - we used to be known as apollo sem):
![]()
The live ad:

And this is what I get when I click through the ad after searching for Homestar Poopsmith (click on the screenshot to enlarge):
The entire page is technically about PPC Management. I added the dynamic text to two headlines on the page…one at the beginning of the content and one towards the middle of the page. The title is also dynamic.
Here is my quality score for the broadly matched term homestar poopsmith:

How will this help you?
Your landing pages will be more relevant to your users AND Google; your quality scores should go up, your costs should come down, and we can expect you to convert more visitors!
Recommendations
Use this pay per click secret with caution! Your results can and will vary!
If you are an ecommerce site with a specific product, you will probably want to carefully include the dynamic search query in your content and titles - maybe you will use empty or open questions like “Are You Looking For (Keyword)?” “This is the closest match…and we think it will be a perfect fit for you because…”
Everybody that implements this secret should aggressively use negatively matched keywords in your campaigns and ad groups.
Creating a dynamic landing page might compromise your SEO strategy. We generally recommend that you duplicate your SEO landing pages (if you are using them for PPC) and place them into a separate file or directory for you to advertise with. Add the “advertisement” directory to the robots.txt file as a disallowed directory to avoid some duplicate content issues.
You will be able to view the exact search terms people are using by filtering through your landing page results in Analytics - another useful way to find negative match keywords.
That’s a wrap! Now You can Create A Dynamic Landing Page in 15 Minutes or Less with PHP!
The originating source of our knowledge regarding this post came from this 2006 Digital Point Forum post.
If you enjoyed this post, make sure you subscribe to my RSS feed or get email updates whenever we write anything new!














January 7th, 2008 at 10:35 pm
James,
Awesome Post I will be using this on a site of mine this week.
January 8th, 2008 at 10:06 am
Nice post again. Your NUDE series is exposing some great secrets!
Also, I like how you have a “great” quality score for “homestar poopsmith” congrats on that one!
January 8th, 2008 at 10:15 am
@Chris - Thanks for the compliment, I’m glad you can use it right away!
@PPC Whiz -
I’m a fan of Homestar Runner…so I thought I would give it a shot. I’ll subscribe to your blog Adam; I’m looking forward to reading your thoughts.
Thank you both for your comments, they are always appreciated!
January 8th, 2008 at 10:22 am
Jameszol… I am a fan of Homestar Runner also. My blog is brand new, not finished the design yet (as you can see) but I wanted to start a PPC education and resources blog. It is a side thing but something I hope will grow.
I will let you know when it is finished and ready for reading!
Adam
January 8th, 2008 at 11:47 am
Unfortunately, as simple as your code example is, it introduces a Cross-Site Scripting (XSS) vulnerability to your page. XSS can lead to all kinds of bad things like session hijacking and browser redirection. Check out these links to learn how to prevent XSS:
http://www.owasp.org/index.php/XSS
http://shiflett.org/blog/2005/jan/xss-cheatsheet
http://ha.ckers.org/xss.html
January 8th, 2008 at 12:11 pm
@John - Thanks for stopping by! It’s great to have a PHP pro like you inform us of this security issue.
I reviewed the ha.ckers.org/xss.html page and it appears that the XSS fix is easy to implement and it simply adds one step to each instance of Dynamic Keyword Insertion on the landing page.
I will make that fix a separate post so everybody that bookmarks/subscribes will see John’s comment and the way to fix it!
January 8th, 2008 at 12:36 pm
The code snippets on the ha.ckers.org site show you different ways to exploit or discover XSS problems. To fix it, you have to properly sanitize the input from the query string variable before you display it on the page. You have an additional issue on your page as it looks like magic quotes are enabled. For example:
http://www.semvironment.com/prosperity.php?kw=james‘
To fix the XSS problem, you’ll need to filter the input. For efficiency, you can do this once, save the output, and use the cleaned variable for displaying on the page.
Right now, your script allows pretty much anything to be injected on the page. In your use case, it seems reasonable that you want to prevent any kind of HTML. After all, this looks pretty silly:
http://www.semvironment.com/prosperity.php?kw=%3Ch1%3EBIG%20TEXT%3C/h1%3E
If this is the case, you can simply use the htmlentities function to escape all tags:
//top of the script
//wherever it appears on the page
On the other hand, if you want to allow HTML, it’s a much harder problem to solve. I recommend this article as a starting point:
http://blog.liip.ch/archive/2005/01/16/xss-how-we-try-to-prevent-it.html
An extreme example of what can go wrong when you allow XSS to persist can be found here:
http://namb.la/popular/
Hope that helps
January 8th, 2008 at 12:38 pm
Oops. Code snippets got filtered:
//top of the script
$cleankw = htmlentities($_GET['kw'],ENT_QUOTES);
//wherever it appears on the page
php echo $cleankw;
January 8th, 2008 at 1:06 pm
[...] While dynamic landing pages are awesome for advertising, and we haven’t had any problems yet after thousands of clicks [...]
January 8th, 2008 at 9:48 pm
Good technique. But not sure whether it will score well with the google webmaster guidelines though !
January 8th, 2008 at 10:04 pm
@Php Programmer - this is meant to be used for PPC only and Google is deeply in favor of anything that increases the relevancy to their users. I’m confident, based on results we’ve seen, that they love this technique - especially when it is very clean and relevant.
January 14th, 2008 at 8:49 pm
NICE! Happen to be something I could use right now.
Thanks
January 24th, 2008 at 5:21 am
Didn’t think that the google ad bot would be including the $_GET[’kw’] parameter when assessing the sites quality score / relevance to the keyword in adwords (as otherwise it would only use your default text). have you confirmed this trail with other examples? just seem to simple
January 30th, 2008 at 1:00 pm
[...] one of my favorites as a highly useful and unique article database, with articles such as: “NUDE: Create Dynamic Landing Pages In 15 Minutes Or Less” and “Getting Conversion Data With Your New Analytics Profile“, this last [...]
February 28th, 2008 at 10:14 am
[...] This is where we get advanced. If you don’t have experience with coding landing pages, don’t freak out – this process is actually pretty simple. Let me take a second to state this fact – I’m not a programmer. I have a high level understanding of code (enough to make minor changes for my clients), and I find this process to be a cinch! The guys over at SEMvironment have blazed this trail already, and I’m going to borrow heavily on their expertise. I would highly recommend you check out their original post. [...]
May 7th, 2008 at 1:38 am
Hatts off! This is what i was looking since days!