Login · Register
Home About Blog

Putting Dynamic Keywords in your Landing Pages

This shows how to dynamically display the keyword the user was searching for on your landing page. This is a simple script that prints the dynamic keyword on the page for users with Tracking202 installed. Below is an example landing page .php file that shows how to place dynamic keywords on your landing page!

Landing Page Code


//grab t202 keyword
$keyword $_GET['t202kw'];

//if a yahoo keyword exists, over-write the t202 keyword
//for Yahoo OVKEY = the bidded keyword, OVRAW = actual keyword
//you can change $_GET['OVRAW'] to $_GET['OVKEY'] if you would
//like to display the bidded keyword, instead of the actual keyword.
if ($_GET['OVKEY']) { $keyword $_GET['OVKEY']; }  

//now anywhere we call echo $keyword, it will display the dynamic kw!

//extra goodie, uncomment the line below if you would like to capitalize 
//the first character in each word
//$keyword = ucwords(strtolower($keyword)); 


        <!-- Display the Dynamic Keyword in the Title! -->
        <title><? echo $keyword?></title>
        <!-- Display the Dynamic Keyword in the body's content! -->
        This is the content on my landing page! You were searching for <? echo $keyword?>.


Anywhere you now call <? echo $keyword?> in your .php file, it will print out the dynamic keyword insertion!


  1. Terrence on Jul 14, 2008 at 7:11am

    Great script!

    Question: Can I use this to get the bidded keyword as well?

  2. Wes Mahler on Jul 15, 2008 at 6:50am

    Sure, the above example should actually grab the bidded keyword, not the actual keyword.

  3. Andre Chaperon on Jul 16, 2008 at 4:01pm


    The "actual keyword" is the important one for me. The bid keyword I already know, of course.

    Is there a way for P202 to record this?


  4. Wes Mahler on Jul 17, 2008 at 2:48am

    Well the ACTUAL KEYWORD is recorded for P202,

    But this script will print the BIDDED KEYWORD, on a landing page.

    So yes it already does it, P202 records the ACTUAL, not the BIDDED keyword.

  5. Ron Berg on Sep 03, 2008 at 2:31pm

    What does {keyword} capture? The actual query or the keyword triggered in the list of keywords?



  6. Steven on Sep 03, 2008 at 3:26pm

    Hi Ron,

    The actual query. It use to grab from the list of keywords but we've disabled that and went with the actual query since it is more accurate of what you would want.

  7. musignr on Sep 10, 2008 at 1:10pm

    Wes, I think this is exactly the script I need.

    I have 100s of keywords and want to setup a SINGLE landing page that displays content that is relevant to the users search term.

    So I insert <? echo $keyword; ?> wherever I want their search term to show up and I'm good. right?

    Also, will this method optimize the landing page for each keyword and help boost Quality Score? Or do you have to create static content pages for each keyword to improve QS?

  8. Wes Mahler on Sep 11, 2008 at 7:23am

    Yes you are correct, go ahead and test-it yourself on a live site, (you'll of course have to click on one of your text-advertisements)

    Although it may not increase your QS by leaps and bounds, it can't help but make it more targeted, you'll probably as well have to create static content, that'll help.

  9. Wes (MasterlessSamurai.com) on Sep 12, 2008 at 10:42am

    The code above works for me if I have the t202kw variable in the URL. When I don't though, I get an error: Notice: Undefined index: t202kw.

    How could I change the code to say "if the t202kw exists, echo keyword, else echo (default keyword)" ?

    I dont want my users to see an error. Most of the time I'll have the t202kw variable in the URL anyway, but if I happen to get some natural traffic or type in, this is when they'll see an error.

  10. jDilleo on Sep 22, 2008 at 2:36pm


    You can replace

    $keyword = $_GET['t202kw'];


    if(is_null($keyword = $_GET['t202kw'])) $keyword='defaultkeyword';

    That should do it.

  11. wowjoomla.com on Oct 25, 2008 at 1:14am

    I have actually created something like this for the Joomla CMS. It essentially displays the the message 'You came from Google looking for {keyword} you may be interesting in the following articles...' it then displays a string of articles.

    However is it my understanding that this can be used within any off the content on a page?

    Is there a way to have a default keyword already in the content (for those who come directly to the site]? For those who come via a search engine the keyword would change from the default.

  12. Mark Pivon on Oct 31, 2008 at 10:46am

    This is excellent! Users may also be interested in a free script that I have created which creates personalized urls. The system pulls data from a database, and populates a template with the database info. So, users are greeted by name, and can even be served personalized images and text - all based on a URL without a login or cookies. Download a free version at http://www.DynamicURLS.com and keep up the good work!

  13. Samuel on Dec 01, 2008 at 6:01pm

    Totally brilliant! That's what I wanted!

  14. Google Search Sux on Jan 17, 2009 at 2:47pm

    I cant get this code to work in Wordpress Blog... wtf

  15. Wes Mahler on Jan 19, 2009 at 7:16pm

    Its because it is PHP code, it probably can't just be dropped into a blog post, it'd have to be in the raw PHP files

  16. mark on Jan 27, 2009 at 6:39am

    Re WP blogs

    Just tested putting Dynamic Keywords on WordPress posts and pages and it works perfect.

    You need Exec-PHP plugin and follow the instructions.


  17. Trevor on Feb 23, 2009 at 9:39am

    What does the code look like when you "uncomment the line below if you would like to captilize

    // the first character in each word"

    Is this correct?: //$keyword = ucwords(strtolower($keyword));

    Any help much appreciated.

  18. brian on May 27, 2009 at 9:26pm

    Question: When running this script in Wordpress, does this mean that I can't use WP-SuperCache on the entire blog so that my landing pages are generated dynamically with keywords each time?

  19. PPCer on Jul 01, 2009 at 8:25am

    I got the script working with the title caps, default text and everything, that's cool...

    However one problem, sure my page includes the searched query as part of title and text and is good for getting conversions, however when I put the default tracking202 destination url in adwords -

    i.e. http://mydomain.com/mypage.php?t202id=1234&t202kw= the end is left with kw= (blank) so I get a terrible quality score...

    If I manually add the terms then I will have overridden the assigned keywords and won't get the actual search queries in my stats... How can I overcome this?

  20. newbie on Jul 20, 2009 at 8:05am

    I'm total noob in prosper202 and ppc but I think that you should try your url with dynamic keyword insertion.

    So your url would look something like this:


    Check out here:


  21. Greg on Dec 13, 2009 at 2:13pm

    Are there any videos to show someone like myself how to install the scripts and where to put the data? Thanks for any help.

  22. Julien on Jan 01, 2010 at 12:38pm

    Hi Everybody,

    This script isn't correct ?

    In Adwords with phrase match, it displays the bidded keyword.

    Could anyone tell me how to display the actual keyword ?

  23. DXL on Feb 17, 2010 at 11:51am

    That script as such is prone to XSS attacks. Instead you should use:


    //Add this to your header

    $keyword = $_GET['t202kw'];

    if ($_GET['OVKEY']) {

    $keyword = $_GET['OVKEY'];


    $keyword = htmlspecialchars($keyword); //Important


    To set a default keyword to be shown if none is present, use the following:


    //Add this to your header

    $keyword = $_GET['t202kw'];

    if ($_GET['OVKEY']) {

    $keyword = $_GET['OVKEY'];


    $keyword = htmlspecialchars($keyword); //Important

    if(!$keyword) {

    $keyword = 'Default keyword';



  24. Nana on Feb 24, 2010 at 8:42am

    Just want to add that DXL is right, use htmlspecialchars()before outputting any $_POST or $_GET variables on your page.

  25. Ranjan on Apr 01, 2012 at 9:41am

    How i can redirect with append the keyword with URL sing landing. I am getting error while doing

  26. Lawrence on Jun 06, 2012 at 5:02am

    Is there any way to pass the data to the landing page using a url like website.com/help (hiding the query keyword)

  27. Sumit on Jun 18, 2012 at 7:57am

    can anyone tell where I have to put this script on landing page?

Leave a Reply

Name (required)

Email (will not be published) (required)


What does 4 + 4 equal? (required spam filter)

Creative Commons License This work (Prosper202, Tracking202 and Export202) is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.