You are here:  » PT SEO Fine Tuning


PT SEO Fine Tuning

Submitted by autopia on Mon, 2008-05-05 04:29 in

Hello David,

First off, let me say thank you and congratulations on a fine bit of work with PT. I was on my way to developing my own until I stumbled on your work. This has saved be months of development. After only 3-4 weeks of work with your product, I have managed to secure $40k plus in advertising contracts.

I would like to do some very specific META tuning for SEO purposes. My experience has shown me that the title, h1 tags, page name, and META description play heavily on page ranking (if the content is rich). With this in mind, I hope to:

1. Append the category title to the end of the product name (e.g., Product Title :: Category Name) to create the page title and the first header tag title at the beginning of each product page. This is important because some marketers are too stupid to use proper key words in their product titles. Also, it will differentiate my page title from theirs, avoiding any potential issues of the SE thinking we have duplicate content.

2. Provide a META description tag containing the first 165 characters from the product description itself (i.e., products.description). This is working very well for me on other sites.

3. Append a category specific file (or database record) to the end of each product page. The file/record will contain content-rich text (e.g., a how-to article) in the range of 500 to 750 words. I eventually see that this text with be tagged with replacement text tokens, where the tokens will be replaced with the product title (hyper linked to the buy page). This will give the search engines even more good text to munch, improving my ability to get pages ranked.

Your guidance on these three mods will be greatly appreciated.

While I'm here, I'd like to share with you exactly how I'm using your product. You might find it interesting to know that I'm not using your import process at all. In fact, the only tables of yours I use are featured and products.

Before finding PT, I started my own project of building a "store reader" that scans the stores of my advertisers and yanks their product data into my database. I did this because the majority of my potential advertisers do not have affiliate programs, let alone an XML or CSV feed file. With just a little work, I can teach my store reader about a new store structure and train it to properly categorize new brands and items within a brand. It also normalizes product names across stores, selecting the title with the best chance of SE ranking. When the nightly store scan jobs are finished, a final job runs that updates the PT products table from my master product table. I run the store reader and data munching jobs on a Windows PC in my garage so I don't burn up valuable bandwidth, cpu cycles and memory on my dedicated server. The final push is done in a matter of a few moments.

Best regards,
David

Submitted by support on Tue, 2008-05-06 07:42

Hi David,

All 3 can be done quite easily; in-turn...

1/
The page title is currently set by the following code in products.php (line 52):

$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);

At this point, the product category will be in the variable $product["products"][0]["category"], so simply change the code above as follows:

$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset)." :: ".htmlentities($product["products"][0]["category"],ENT_QUOTES,$config_charset);

2/
On the line after the line that sets the title (see above), you will see the following code that sets the current meta description:

$header["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);

At this point, the description is in the variable: $product["products"][0]["description"], so simply change the above code as follows to use the first 165 characters of the description:

$header["meta"]["description"] = htmlentities(substr($product["products"][0]["description"],0,165),ENT_QUOTES,$config_charset);

As a slight tweak to the above which might break off the description mid-word; have a look at the following alternative (based on code I wrote in this thread) which will crop the description at the next space AFTER the size required:

$description = $product["products"][0]["description"];
$breakLimit = 165;
if (strlen($description) > $breakLimit)
{
  $breakOffset = strpos($description," ",$breakLimit);
  if ($breakOffset !== false)
  {
    $description = substr($description,0,$breakOffset);
  }
}
$header["meta"]["description"] = htmlentities($description,ENT_QUOTES,$config_charset);

3/

Several users have implemented a mod to append their own product (or just as easily category) related content to the end of the product page. The most straight forward way is to create yourself a directory containing the files containing the text you want to add that have exactly the same name as the product itself - or in this case the category.

For example, if you create a folder in your Price Tapestry installation directory called "categoryinfo", you could then add the following PHP anywhere within, for example, html/product.php:

<?php
  $filename 
"categoryinfo/".$mainProduct["category"];
  if (
file_exists($filename))
  {
    require(
$filename);
  }
?>

You mentioned going a step further and using replacement tokens - that just be a case of loading the file into a string, making the replacements as required, and then printing the string instead of just require()'ing the filename.

Hope this helps!

Cheers,
David.

Submitted by Leo on Fri, 2008-05-16 17:53

Hi David i have wrote you a mail to in the morning.

i have try this code from above.

<?php
  $filename = "categoryinfo/".$mainProduct["category"];
  if (file_exists($filename))
  {
    require($filename);
  }
?>

On some merchants it works and some not have been bussy with it for days to get it to work.
I finnaly find the problem if from some merchants the category is not used/imported you get the error permission denied blah blah.
My question is is there a possibility when a category is empty (not imported) that you can get some kind of if statement? If category empty no error.

Another thing i try'd and not get fully working is this i have make a layout with content and a right menu/side. When i put the same code in the right menu it works fine when you go to the category page or searchresults page. But when you click on merchants, brands or another page you get the error permission denied is there something to fix for you think?

Leo

Submitted by support on Fri, 2008-05-16 18:16

Hello Leo,

I think I see the problem.

If the category is empty; then it just tries to require() the directory! And that creates an error. To fix this, try changing the code to this:

<?php
  
if ($mainProduct["category"])
  {
    
$filename "categoryinfo/".$mainProduct["category"];
    if (
file_exists($filename))
    {
      require(
$filename);
    }
  }
?>

The second problem sounds like the same thing. What code do you have in your right menu? Can you post an example?

Cheers,
David.

Submitted by Leo on Fri, 2008-05-16 19:56

Hi David,

Everything works now even the second problem I used your first code for the right side just changed $mainProduct to $product so the text is not showing only on the product detail page but on the whole category.
The first orginal code for the extra product description was this one i changed it with your new code and it works perfect. I use brand for some extra text for product detail and category for the categories.

<?php
  if ($mainProduct["brand"])
  {
 $filename = "extraplaats/".$mainProduct["brand"];
   if (file_exists($filename))
  {
  print '<div class="blokcontent gray">';
print'<div class="bottom_border_right">';
print '<div class="top_border_right"></div>';
print'<div class="content_box_small">';
# print '<h4>Informatie</h4>';
# print '<br />';
require($filename);
print '</div> <div class="bottom_border_left"></div></div></div>';
}
}
   ?>

You are a genie thanks.

Can you maybe when you have time later answer my other question on the email

Submitted by autopia on Mon, 2008-05-19 23:25

David,

All of these changes and a couple more tweaks went in with ease. In the week since I made the change I already see pages increasing in Google rankings.

Thanks for your time and effort on this one!

David

Submitted by Al on Sun, 2008-05-25 11:46

I did step 1 and 2. But when I look to the source of my pages, I do not see ANY meta tags at all... Only the page title is shown correctly.

Submitted by Al on Sun, 2008-05-25 11:52

ref my previous posting:

I do not see any meta tags on my 'home' page. I think search engines need those???

I only see them in the source when I a product is displayed.

I have made a menu, to quickly search for products. These search result pages do not have any meta tags...

How can I add them? And where?

Thanks a lot for your reply.

Submitted by support on Mon, 2008-05-26 07:16

Hello Al,

Please see the following page for the code to add meta tags to your home page:

http://www.pricetapestry.com/node/176

You can also use the code from that thread on any other page - simply look for require("html/header.php"); and make sure that you set $header["meta"]["keywords"] (and any other meta tags you wish to include) before header.php is called and your meta tags will be displayed!

To add search related meta tags to the search page; you want to do a similar sort of thing in search.php. However, rather than add the code immediately before the line to include the header; I would add them further up at a point at which you know you have got search results. For example, look for the following code:

$navigation["resultCount"] = $resultCount;

..and then add the meta tag code on the next line(s), using $q to incorporate the query into the tags:

  $header["meta"]["description"] = "Price comparison search results for ".$q;
  $header["meta"]["keywords"] = $q;

Cheers,
David.

Submitted by Al on Sun, 2008-06-01 19:31

Thank you, David.

Submitted by ajmboy on Wed, 2012-04-25 12:22

I'm using this code in products.php:

$description = $product["products"][0]["description"];
 $breakLimit = 165;
 if (strlen($description) > $breakLimit)
 {
   $breakOffset = strpos($description," ",$breakLimit);
   if ($breakOffset !== false)
   {
     $description = substr($description,0,$breakOffset);
   }
 }
 $header["meta"]["description"] = htmlentities($description,ENT_QUOTES,$config_charset);

But is seems to add some white spaces in the description meta tag. Any ideas?

Submitted by support on Wed, 2012-04-25 12:48

Hi ajmboy,

It's most likely that the white space is in the description already - one thing to do would be to sanitsise as follows - where you currently have:

$description = $product["products"][0]["description"];

...REPLACE that with:

$description = trim($product["products"][0]["description"]);
$description = preg_replace('/[ ]{2,}/',' ',$description);

That will remove any white space from the beginning or end; and the second line will replace any sequence of 2 or more spaces with a single space...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Fri, 2012-04-27 11:56

Perfect! Thanks.

Submitted by bem on Thu, 2012-05-03 21:01

Hi David ,

Some of my merchants use the tag at in their descriptions, which I like so don't really want to remove. But when using this, the meta description starts with <p>

Is there anyway this can be removed just from showing in the meta description?

Thanks, Ben

Submitted by support on Fri, 2012-05-04 09:50

Hello Ben,

Sure - on the line after the modification to use a product description as the meta description, simply add this line:

  $header["meta"]["description"] = strip_tags($header["meta"]["description"]);

Cheers,
David.
--
PriceTapestry.com

Submitted by rolli1 on Sun, 2012-05-13 09:55

Hi David,
I think I have a more simple solution for the Title and description tag.
I privide the title tag direct coded, e.g.

<title> Dark clothing</title>

and for description:

" Here you get dark clothing"
This tag I add:

<title> <?php print $q?> Dark clothing</title>
" Here you get <?php print $q?> dark clothing"

The result is a separate title and description tag for each search.

I so. searches moonlight

then the title tag is: <title>Moonlight dark clothing</title>
and the description tag is:

"Here you get moonlight dark clothing".

The only problem results in too long search expressions.

Perhaps there ist a possibility to shorten that?

Regards

Roland

Submitted by support on Mon, 2012-05-14 08:31

Hi Roland,

Looks good; don't forget to use htmlentities() around $q when printing, e.g.

<title> <?php print htmlentities($q); ?> Dark clothing</title>
" Here you get <?php print htmlentities($q); ?> dark clothing"

Cheers,
David.
--
PriceTapestry.com

Submitted by chrisst1 on Mon, 2012-05-14 18:23

Hi David

I am using the following custom code in products.php :

 // START CUSTOM
  $meta_sql = "SELECT * FROM `".$config_databaseTablePrefix."productsmap` WHERE name='".database_safe($product["products"][0]["name"])."' LIMIT 1";
  database_querySelect($meta_sql,$meta_rows);
  if (isset($meta_rows[0]["meta_title"]) && ($meta_rows[0]["meta_title"]!=""))
  {
    $header["title"] = htmlentities($meta_rows[0]["meta_title"],ENT_QUOTES,$config_charset);
  }
  else
  {
    $header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
  }
  if (isset($meta_rows[0]["meta_description"]) && ($meta_rows[0]["meta_description"]!=""))
  {
    $header["meta"]["description"] = $meta_rows[0]["meta_description"];
  }
  else
  {
    //$header["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
// START CUSTOM
    $description = $product["products"][0]["description"];
    $breakLimit = 165;
    if (strlen($description) > $breakLimit)
    {
    $breakOffset = strpos($description," ",$breakLimit);
    if ($breakOffset !== false)
    {
    $description = substr($description,0,$breakOffset);
    }
    $header["meta"]["description"] = htmlentities($description,ENT_QUOTES,$config_charset);
    }
// END CUSTOM
  }
  if (isset($meta_rows[0]["meta_keywords"]) && ($meta_rows[0]["meta_keywords"]!=""))
  {
    $header["meta"]["keywords"] = $meta_rows[0]["meta_keywords"];
  }
  else
  {
    $header["meta"]["keywords"] = htmlentities($q,ENT_QUOTES,$config_charset);
  }
// END CUSTOM

What i am finding is that descriptions of less than the breakLimit are not showing any results nor the meta tag where as descriptions over the breakLimit are showing and being cut of correctly.

Any ideas

Chris

Submitted by support on Tue, 2012-05-15 08:56

Hi Chris,

The line to actually set the meta description tag:

  $header["meta"]["description"] = htmlentities($description,ENT_QUOTES,$config_charset);

...appears within the if (strlen($description) > $breakLimit) construct whereas it should be the first line after it; that's why it's not being set for descriptions shorter than $breakLimit - that section I think should be:

// START CUSTOM
    $description = $product["products"][0]["description"];
    $breakLimit = 165;
    if (strlen($description) > $breakLimit)
    {
      $breakOffset = strpos($description," ",$breakLimit);
      if ($breakOffset !== false)
      {
        $description = substr($description,0,$breakOffset);
      }
    }
    $header["meta"]["description"] = htmlentities($description,ENT_QUOTES,$config_charset);
// END CUSTOM

Cheers,
David.
--
PriceTapestry.com

Submitted by chrisst1 on Tue, 2012-05-15 19:35

Thanks David

Submitted by bat on Tue, 2012-12-25 13:17

Hi David,
How can I make the following code show the product name followed by the description, for the meta description, please? I've tried adding $q, in front of $description which didn't work. :)

$header["meta"]["description"] = htmlentities($description,ENT_QUOTES,$config_charset);

Submitted by support on Wed, 2012-12-26 09:25

Hi bat,

Use $product["products"][0]["name"] at that point - have a go with:

$header["meta"]["description"] = htmlentities($product["products"][0]["name"],ENT_QUOTES,$config_charset)." ".htmlentities($description,ENT_QUOTES,$config_charset);

Cheers,
David.
--
PriceTapestry.com

Submitted by bat on Thu, 2012-12-27 11:46

Perfect, thank you David.