Quickly Add Open Graph tags to Magento

A client of mine recently shared the site report for her site from Silktide with me and it showed a few things needed improving, particularly the Open Graph integration. Her site is a new Magento store, built on Magento Community Edition 1.7.02 and whilst I’d added share buttons to the product pages via the ShareThis widget I hadn’t added in any Open Graph tags to optimize the sharing process. The Silktide report spurred me in to action and I thought I’d share my code to quickly add the OG tags to your magento pages.

First you’ll need to edit your theme’s head file at “app/design/frontend/YOURTHEME/default/template/page/html/head.phtml” and add the following lines of code:


<meta property="og:site_name" content="<?php echo Mage::app()->getStore()->getGroup()->getName(); ?>" />
<meta property="og:description" content="<?php echo strip_tags(htmlspecialchars($this->getDescription())) ?>" />
 
<?php if (!in_array(Mage::app()->getFrontController()->getAction()->getFullActionName(), array('cms_index_noRoute', 'cms_index_defaultNoRoute'))) {
    $currentUrl = Mage::helper('core/url')->getCurrentUrl();
}?> 
<meta property="og:url" content="<?php echo $currentUrl ?>" />
 
<?php if (Mage::registry('current_product')) : ?>
<?php if (Mage::registry('current_product')->getMetaTitle() == "") {
  $ogTitle = Mage::registry('current_product')->getName();
} else {
  $ogTitle = Mage::registry('current_product')->getMetaTitle();
}
?> <meta property="og:title" content="<?php echo $ogTitle ?>" />  

<meta property="og:image" content="<?php echo Mage::helper('catalog/image')->init(Mage::registry('current_product'), 'small_image')->resize(200,200);?>" />
<?php endif;?> 

This code is mainly aimed at product pages and sharing them on Facebook so it renders the product’s title, description and a thumbnail image of the product, resized to the recommended size of 200 pixels square. Any HTML in the description is stripped out leaving the plain text. The code also adds the current store view’s name (you may need to edit this in Configuration > Manage Stores) and the URL of the current page. Finally the code checks if the product has a Meta Title set and if not it displays the name of the product instead. Upload the altered file, clear your Magento cache and away you go. You can check your integration with the Facebook debugger tool.

UPDATE
The code below checks if we’re on a product or category page and pulls the relevant image and sets the correct og:title for the category or product page.


<?php if (Mage::registry('current_category')) : ?>
<?php $ogTitle = Mage::registry('current_category')->getName();?>
<?php
$_category  = Mage::registry('current_category');
$cur_category = Mage::getModel('catalog/category')->load($_category->getId());
$imageUrl = $cur_category->getImageUrl();
?>
<meta property="og:image" content="<?php echo $imageUrl;?>" />
<?php endif;?>
<?php if (Mage::registry('current_product')) : ?>
<meta property="og:image" content="<?php echo Mage::helper('catalog/image')->init(Mage::registry('current_product'), 'small_image')->resize(200,200);?>" />
<?php endif;?>
<meta property="og:title" content="<?php echo $ogTitle ?>" />

I still haven’t found a way to get all the product images but it will be necessary to loop throught the product image array and write out an og:image tag for each image.

5 Essential Magento extensions for UK shopping sites.

I’ve been spreading my wings lately and offering low cost e-commerce solutions using Magento Community as the base for websites. Magento Community is a fine piece of software with a mind-boggling array of features and options but it does lack certain abilities that make it a truly great product. Thankfully due to the open-source nature of Magento there are plenty of extensions available to make Magento do what you want it to do.

Yoast MetaRobots
This exension by the respected Yoast (known for his excellent WordPress SEO extension) allows you to control the Meta Robots tags quickly and easily on a variety of pages on your Magento site to help direct the flow of “link juice” around the site and prevent pages from being indexed. Yoast MetaRobots allows you to set pages such as Send to a Friend, Customer Account pages, Tags and Checkout as “noindex, follow” from a simple panel in the System > Configuration  > Web section of Magento’s administration area.

MSemantic
Now that Google (and Bing to a lesser extent) are really pushing Rich Snippets as an important part of your site’s content it is imperative that your Magento site implements semantic markup for Rich Snippets for Google and Bing. The MSemantic extension takes away all the pain of marking up your site with a simple to install extension. Once installed your products and reviews contain the correct markup for Rich Snippets integration which will help with your rankings and visibility in Google, Google Shopping and of course Bing.

Google Content API for Shopping
The only way to get your products listed on Google Shopping if you use Magento. Simply install the extension, add your Account ID, Google Account Email Address and Password and then upload your selected products to Google. You can configure the extension to automatically update the product listing on Google if you change the product in any way and it’s easy to see what products you have listed and what needs adding. The extension also supports custom attributes and the full range of Google Shopping taxonomies.

Meanbee Royal Mail Domestic and International Shipping
This simple to use extension adds the current Royal Mail shipping costs to your Magento store and works out the correct postage cost based on location and weight. My 2 qualms with this extension are you can’t add the cost of your packaging materials to the shipping rates so you would have to add a bit extra on to each product’s cost or define a shopping cart rule to get a more accurate cost and the extension does not take the packet’s dimensions in to account as it’s based purely on weight. Otherwise this extension is fantastic and a really simple way to set up Shipping Table Rates in Magento for UK users.

Clever CMS
Magento’s Content Management System is a bit… well, basic to polite, but Magento is primarily an e-commerce solution not a fully featured CMS. Clever CMS extends the basic Magento CMS with some great additions that I feel are essential to any good CMS. Clever CMS allows you to assign permissions to your pages so you can decide who sees your pages (logged in customers, not logged in customers, etc.) and more importantly creates a tree structure for your pages similar to Magento’s category tree structure so you can create sub pages and rearrange your menus at will and each store view can have it’s own “tree”. You can define your own URLs and if you change them at a later date then Clever CMS will set up a 301 redirect from the old URL to the new one.

Is Google removing free directories from it’s index?

This is my first post in a long time on my often neglected blog and I thought I should come back by answering a question a lot of people have been asking on the SEO forums and sites recently, “is Google removing free directories from it’s index?” Barry Schwartz highlighted the issue over on Search Engine Round Table and claimed that over 50% of the directory sites he checked had been de-indexed. Search News Central followed that up with a test of over 400 directories and found that just over 1% had been de-indexed. I used to use a lot of free directory submissions when I was starting out and built up quite a list of directories that I knew were good for a link, would show up on Google and were regularly crawled. I checked this list of just under 200 directories to see if any had been deindexed and the results were… underwhelming. Out of 191 sites 2 were no longer online so had been de-indexed, 4 were still active but had been de-indexed due to server errors or just plain crap coding or set up and 1 had only the home page indexed. The rest were fine. So in short the answer to the question above is… no.

It may be that after the Penguin update that these free directories are no longer passing as much or any link juice as before, it may be that these sites are fine. As I said earlier this list is a hand-crafted list of free directories that have been proven to work pre-Penguin, post-Panda and long before that. So is Google removing quality free directories? No, but it might be removing the crap ones and about time too.

Removing Voltrank Increased My Rankings

Following on from my recent post about Voltrank’s ineffectiveness at increasing rankings I thought you may be interested to know what effect that has had on rankings. A week on from deactivating and uninstalling Voltrank my rankings for my entire site have shot up considerably. I mentioned 2 target phrases in my original post and for the the first of these, “bra measuring guide,” my site is not firmly in the top 10 of Google UK and for the second, “lingerie guide,” the page is hovering around postion 15 or 16. Rankings across the site have improved immensely for many of the keywords I’m tracking for the site with a few top 10 and top 20 results just a week after being nowhere in the top 200! I am aware that some of this boost may be coming from the links I placed in my previous post but that wouldn’t really explain the site wide jump. I mean this blog isn’t exactly popular so there’s very little link juice flowing around. I think this just reinforces that my experience with Voltrank was bad. To back this up, here’s a screen shot from my Google Analytics account for this site:

Yep that’s five fold increase in traffic after the site was re-ranked. Yes it’s only 14 or 15 a day but it’s a lot better than 2 a day!

Free Link Exchange Programs That Don’t Work – Linkalizer

In the second post in my series of Free Link Exchange Programs That Don’t Work I’m looking at Linkalizer. I’d like to start by pointing out that it’s been a few years since I actively used Linkalizer as I realized a while ago that it was crap! I checked my records and I signed up in 2007. It may have changed in the last few years but by looking at the website I’d say it hasn’t! One quick glance through the Link Exchange Directory on the site (where all sites that join Linkalizer are listed) shows us that there is very little care or attention put in to this system. Looking at the Arts section of the directory shows us that Linkalizer is full or spam and misfiled sites. There’s a Nigerian Job Centre site, Google Classified Ads site, NTFS data recovery, college party tips, Warcraft sites, a technology new blog, corsets site, the obligatory Vietnam travel site and “Medical tourism in India” all on the first page of the Arts directory. This tells us the sites aren’t being reviewed and anyone can join. I tested a handful of links from various pages in the directory on Yahoo! Site Explorer and none of them showed a backlink from Linkalizer’s directory so it’s not even worth joining for a free followed link from their directory as it will never be counted!

Linkalizer is a simple link exchange system, you link to someone else’s site and they will link back to you. Free members can send a limited number of link requests per day and respond to incoming requests. Members can search the directory and request links from any site in any category. Unfortunately this means you will be inundated with link requests from poor quality sites, unrelated sites and makes finding the good sites even harder. The directory lists the PageRank for each site (because that’s such a reliable metric…) and a link to the Alexa data for the site so if you want to find any good sites you’re going to have to do some serious digging with 3rd party tools. You can’t search the directory, only browse the listings which makes finding link prospects even more time consuming.

As I said before it’s been a few years since I used Linkalizer and maybe if you were determined enough and did enough analysis of your link exchange prospects you could get some strong backlinks from this system but you would spend most of your time in the dashboard rejecting link requests from spammy sites. If you are looking for sites to exchange links with then avoid this system and stick to looking for link exchanges manually.

Don;t forget to check out part one of this series, our review of Voltrank.