Greeting your first time visitors and encouraging them to subscribe

10 Jun

One of the glories of the web is the number of visitors that come to your website / blog via longtail search terms – it can drive lots of targeted traffic but often visitors come to the site only the once.

A small bit of php can be integrated into wordpress to try and combat this. Take a look at the screenshot below:

New User Screenshot

Now just follow our few easy steps to integrate this into your wordpress installation:

1) Save cookie.php.txt to cookie.php somwhere locally.
2) Open up cookie.php.txt and change the text and feed URL to match that of your server.
3) Upload the file to the root directory of your server.
4) Open up your wordpress backend (wp-admin) and select “Presentation” then “Theme Editor”.
5) Select style.css on the right and add the following code (you can modify it to change the colors, etc) in the file somewhere:

 

/* Cookie style document */

.cookiestyle {
width:450px;
text-align:left;
padding:5px;
background-color:#EAF4FF;
border:1px solid black;
font-size:12px;
margin-bottom:15px;
}

6) In the Theme Editor, select “Main Index template” and insert the following line:

<?php include(“cookie.php”); ?>

This should generally go near the top of the file and in my theme is above:

<?php $countervariable=1; if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

Do the same with the Single Post page

7) Re-visit the site and you should now see the message display – Refresh and it will disappear.

It’s another “nice touch” and if your content is high quality it may well encourage your visitors to sign up to the RSS feed and visit more often.

5 Responses to “Greeting your first time visitors and encouraging them to subscribe”

  1. Kim 19. Jun, 2007 at 12:39 am #

    Hi-

    Thanks for the tip, but I’m having a problem with it as it relates to the location of the cookie file and then calling it from the page. I have it in the root of my wp installation, but when I add the code as directed in step 6 above, I get a php error:

    include(€cookiephp€) [function.include]: failed to open stream: No such file or directory in /…/wp-content/themes/MistyLook/index.php on line 11

    Warning: include() [function.include]: Failed opening ‘€cookiephp€’ for inclusion (include_path=’/…/wp-content/plugins/xdforum/includes/htmlpurifier/library:/…/wp-content/plugins/anotherFlickr/phpFlickr/PEAR:.:/usr/lib/php:/usr/local/lib/php:/…/wp-content/plugins/anotherFlickr/phpFlickr/PEAR’) in /…/wp-content/themes/MistyLook/index.php on line 11

    Any tips? I know the problem is with the “cookie.php” call but I don’t know how to change it to fix it. I’m only good enough with php to cause problems.

    Thanks

  2. James 19. Jun, 2007 at 5:06 am #

    I am assuming you are using in the include cookie.php, rather than cookiephp (as there doesn’t seem to be a dot in the error message).

    If you are, you could try and place the cookie.php file in one of the inclusion paths or put the path before it – i.e. include “/€¦/cookie.php” or something along those lines..

    Let me know how you get on.

    Cheers
    James

  3. Kim 19. Jun, 2007 at 12:39 pm #

    Indeed- the dot is there as copied from the site… maybe that’s a clue…
    I tried moving the cookie.php file to the themes folder for kicks to see if it was a path issue but got the same result.

    Since there’s a problem with the function I wonder if there’s a piece of code missing there somewhere, in either the theme functions or the main functions?

    I’m really just talking out the top of my head because I’m quite unsure of what’s happening.

  4. jp 29. Jun, 2007 at 3:21 pm #

    “Refresh and it will disappear.” No its not disappearing. :(

Trackbacks/Pingbacks

  1. Wordpress SEO « Alemele’s Weblog - 20. Feb, 2008

    [...] Greeting your first time visitors and encouraging them to subscribe [...]

Leave a Reply

Spam Protection by WP-SpamFree