Track Magento Search Keywords in Google Analytics

Here’s a quick tip for those of you looking to get more information about how your visitors behave on your website. Magento has built in features to track keywords visitors are using to search your site. You can see those keywords by logging in to the Magento admin, and going to Catalog > Search Terms. This is great to see exactly what people are searching for, but the data is not very actionable. Wouldn’t it be great if you could track those keywords in Google Analytics “Site Search” reports and segment those visitors to find which keywords are converting the best? Well, here’s how you do that.

Login to Google Analytics, and click on the profile you want to track site search keywords. Click the Admin tab on the very far right, then choose a website within that profile. Then you need to click the “Profile Settings” tab. At the bottom of that page you’ll see a “Site Search Settings” section. Here’s what you want your settings to look like:

Google Analytics - Site Search Settings

Google Analytics - Site Search Settings

First, select “Do Track Site Search” and we are using the query parameter as “q”. What this means is it’s going to parse any URL within your website that uses the query parameter like: http://www.cornerstonejewelrydesigns.com/catalogsearch/result/?q=purity+rings. Next you’ll want to enable the “Site search categories” and input “cat” as the query parameter. This will allow you to track the categories that the users clicks on after they’ve done their search. For example: http://www.cornerstonejewelrydesigns.com/catalogsearch/result/index/?cat=22&q=earrings. Click “Apply” and that’s it! It could take up to 48 hours to start seeing search results. After that, your results should look something like this:

Google Analytics - Magento Search Terms


Magento SEO Tips – How to Get Some Love from Google

So you just built your brand new website using Magento Commerce. You’ve customized your design, added products, created categories, and have the store configured perfectly. But there’s one problem. Your website has no traffic and consequently zero sales. That’s a huge problem and we’re going to give you some free advice on how to fix it. This article is perfect for beginners and non-tech savvy store owners but even those with advanced skills may learn something!

Setup Google Analytics

This isn’t really SEO advice perse, but you won’t know where your traffic is coming from if you don’t have some type of analytics. We recommend Google Analytics because a) it’s free, and b) it’s awesome. If you’ve already created your Google Analytics account, login to Magento and go to System > Configuration > Sales > Google API > Google Analytics and paste your account number in the Account Number field. It should look something like this: UA-XXXXXXX-X. Magento works with Google Analytics out of the box so you don’t have to do anything else to integrate the two.

Register Your Site with Google Webmaster Tools

Google Webmaster Tools is great for website owners. You can view exactly how Google see’s your site and find any problems that may occur when they crawl your pages.

Auto Redirect Base-URL using 301 Redirects

It’s important that Google only see’s one version of your homepage. For example, most websites can be accessed by visiting http://mydomain.com and http://www.mydomain.com. Magento has a solution to this but the default setting is for a 302 Redirect instead of a 301. The difference is that the 301 Redirect will pass some “link juice” and a 302 Redirect doesn’t. So let’s say you get a bunch of links to your website without the WWW in the URL. Magento will redirect any visitor that accesses the non-www URL to the correct WWW URL. This is great for visitors, but if the redirect is a 302 Google won’t pass any link love to the correct URL. To change this, login to Magento and go to System > Configuration > General > Web > URL Options. We want to change the “Auto-redirect to Base URL” to “Yes (301 Moved Permanently)”. Click Save or remain on the same page for the next tip.

Enable Web Server Rewrites

We want our Magento URL’s to look pretty so under System > Configuration > General > Web > Search Engine Optimization, make sure “Use Web Server Rewrites” is set to Yes.

Avoid Duplicate Content by Disabling Category URLs

This is a tip that is often over looked. By default, Magento will use the category structure in the product URL. For example, yourwebsite.com/category-name/product-name.html. This is a bad idea because you may have some products that exist in multiple categories. The best URL structure would be yourwebsite.com/product-name.html where the category name isn’t in the URL. To change this, login to the Magento admin and go to System > Configuration > General > Catalog > Catalog > Search Engine Optimization. We want to change the setting “Use Categories Path for Product URLs” to No. While you’re there, make sure the following fields are set to Yes: “Create Permanent Redirect for old URLs if Url key changed”, “Use Canonical Link Meta Tag For Categories”, “Use Canonical Link Meta Tag For Products” (though this shouldn’t really be an issue if you changed the category path for product URLs setting).

Setup Your Google Sitemap and Submit it in Webmaster Tools

Having a sitemap allows Google to see all of the products, categories, and CMS pages on your site. No matter what, Google will always determine wether or not that specific page belongs in their index, but a sitemap is a great way to speed up the indexing/crawling process. Especially for new sites. To setup a Google sitemap with Magento, check out thiseasy to follow tutorial. After that, you should login to Webmaster Tools and submit your sitemap under “Site Configuration > Sitemaps”.

Create a robots.txt File

It’s very important that you have a robots.txt file in your website’s root directory so Google knows which files and directories to ignore. Magento relies heavily on query strings when dealing with pagination of products on category pages. Here’s what our typical robots.txt file looks like:

User-agent: *
Disallow: /index.php/
Disallow: /*?
Disallow: /*.js$
Disallow: /*.css$
Disallow: /checkout/
Disallow: /tag/
Disallow: /catalogsearch/
Disallow: /review/
Disallow: /app/
Disallow: /downloader/
Disallow: /js/
Disallow: /lib/
Disallow: /media/
Disallow: /*.php$
Disallow: /pkginfo/
Disallow: /report/
Disallow: /skin/
Disallow: /var/
Disallow: /customer/

Hopefully these tips will help you get some love from Google. If you’re interested in our Magento Search Engine Optimization consulting services, visit our “Get a Quote” page to contact us.

* Update * – This post applies to the most recent version of Magento (1.7.0.0)


Track Page Load Times in Magento Using Google Analytics

Magento and Google Analytics

In 2010, Google announced that they are using “Site Speed” as one of hundreds of factors in their organic search algorithm. This means that you’re going to want your pages loading as fast as possible for visitors so you can potentially get that extra boost in rankings. While site speed isn’t going to make a huge difference in your rankings, it may give you that little bump you need to overtake a competitor in the search results.

Now it’s more important than ever to track page loading times for your visitors and Google Analytics has come to the rescue. In a recent update, Google has added the ability to track your visitor’s page load time. All you need to do is add one line of code to your existing Google Analytics tracking script and you’ll get a sample of page load data from your website’s visitors.

For those of you using Magento Commerce, you’re well aware that page load times can be an issue due to the amount of server resources Magento hogs. Unfortunately the logging in Magento isn’t detailed enough to capture page loading times in an easy to read format. We can now solve that problem by editing the magento block that calls the Google Analytics script. Here’s how you do it:

First, you need to create this folder structure in your Magento installation: /app/code/local/Mage/GoogleAnalytics/Block/

Then you need to copy the file /app/code/core/Mage/GoogleAnalytics/Block/Ga.php to the folder you just created (/app/code/local/Mage/GoogleAnalytics/Block/). This ensures that you don’t edit the core files of Magento and that any changes you make to this file won’t be overwritten in the next Magento update.

Once you do that, open up the file you just created (/app/code/local/Mage/GoogleAnalytics/Block/Ga.php) and go to line #164 (for Magento version 1.5.1 – If you have a different version then the line will be different but the concept doesn’t change).

Original Code:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
    (function() {
        var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
        ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
        (document.getElementsByTagName(\'head\')[0] || document.getElementsByTagName(\'body\')[0]).appendChild(ga);
    })();

    var _gaq = _gaq || [];
	' . $this->_getPageTrackingCode($accountId) . '
	' . $this->_getOrdersTrackingCode() . '
//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->';

New Code:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
    (function() {
        var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
        ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
        (document.getElementsByTagName(\'head\')[0] || document.getElementsByTagName(\'body\')[0]).appendChild(ga);
    })();

    var _gaq = _gaq || [];
	' . $this->_getPageTrackingCode($accountId) . '
	' . $this->_getOrdersTrackingCode() . '
	_gaq.push(["_trackPageLoadTime"]);
//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->';

All we did was add the following code right above //]]>:

_gaq.push(["_trackPageLoadTime"]);

That’s it! After a few days you should see a page load data in the new version of Google Analytics. It should look something like this:

Google Analytics Site Speed