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 Hosting for Serious Stores

Finding a host that can handle a Magento installation is not that hard. After all, it’s written using PHP / MySQL which almost every host is capable of these days. The problem is finding a Magento hosting provider that knows what they’re doing. When we first started working with clients using Magento back in 2009, we went through several different hosts and finally found the perfect Magento hosting company: Nexcess.

Magento is FAST on Nexcess

The number one complaint about Magento is that it’s slow. There are a few things you can do to speed up magento, but ultimately your site is limited by the server that’s running it. Nexcess has created specific Magento hosting plans that run really really fast. Other hosting companies claim their servers are built for Magento but they have no data to back up those claims. Click here to view all the details about how they optimize for Magento.

24-7 Support

Support is the most important part of a hosting package. There is nothing worse than having your website go down outside of a hosting company’s normal operating hours. Nexcess has 24-7 support and it truly is 24-7.

We do most of our Magento upgrades outside of peak traffic hours which just so happens to be around 2 am. One time we had a problem during an upgrade and sent an email to Nexcess support. Within 15 minutes we received a reply and were able to instantly solve our upgrade issue. Their claim to 24-7 support is legit, unlike every other hosting company we’ve dealt with.

Limited Accounts per Server

Hosting companies love to over promise and they especially love to oversell. The great thing about Nexcess is that they limit a total number of stores per server so you don’t have to worry about your store slowing down over time.

Nightly MySQL Backups

Backing up your Magento store is important. Nexcess does nightly MySQL backups so that you don’t have to login to Magento and run a backup manually.

SSH Access

Not all Magento hosts will allow you to have access to the site through SSH. Most people won’t need to use this, but those that know their way around the shell will love this feature. SSH isn’t set up by default, but if you email support@nexcess.net with your IP address they’ll enable it.

Overall, Nexcess is one of the best Magento hosting companies out there. If you’re having trouble with your hosting company, let us know and we’ll help you move everything over to Nexcess.


Speed Up Magento with Lightspeed

Magento is an amazing ecommerce platform, but there is one glaring issue that haunts every Magento developer. It’s slow. Excruciatingly slow. There’s a few things you can do to help with the page load times like using the built in caching system, combining your javascript and css files, using Memcached, etc. Those fixes can definitely help, but they’re not going to make a significant difference. Magento Community Edition needs full page caching, and until then, you’re stuck with 3rd party modules that can solve this problem. We looked at several full page caching modules and decided to purchase TinyBrick’s Lightspeed based on some positive reviews.

What is Lightspeed?

Lightspeed is an extension that offers full page caching for Magento Community edition. It works by taking a snapshot of the page when it’s first loaded. The next time a browser requests that page, Lightspeed loads the snapshot instead of the full page with all the server side scripting and database calls. The result is insanely fast page load times that will make you and your customers very happy.

How Much Faster is Magento with Lightspeed?

Lightspeed will make your Magento store run fast. Like, really really fast. Don’t believe me? Thanks to magespeedtest.com we can show you how much of a performance boost you’ll get with Lightspeed.

Magento Page Loading Time Comparison

Comparison of Magento with/without Lightspeed Installed

As you can see, the longest loading time during our test with Lightspeed installed was 2.37 seconds compared to 7.33 seconds without it. The shortest time was .19 seconds compared to 2.84 seconds. Now ask yourself this, would you rather wait 2.37 seconds? Or 7.33 seconds? Your customers feel the same way!

Installing Lightspeed

Lightspeed is actually really easy to install if you follow the installation guide. The instructions make it seem like you’re going to have to be an expert, but it’s not that hard if you have some experience installing Magento extensions. Before you do anything though, make sure you backup Magento.

Once you’ve uploaded the files, you then need to update your .htaccess file to use lightspeed.php instead of index.php. You’re going to want to modify these two lines:

DirectoryIndex index.php
DirectoryIndex lightspeed.php

RewriteRule .* index.php [L]
RewriteRule .* lightspeed.php [L]

If you have customized the .htaccess file then you’ll to do a find and replace for index.php. After you’ve done that, refresh your cache and you should be good to go!

Hole Punching in Lightspeed

There are some cases that you want to load dynamic content on the page instead of the static HTML. For example, most shopping sites have a shopping cart widget in the header area that shows how many products are in the cart. Fortunately, the creators of Lightspeed have a way around this through “Hole Punching”. Hole Punching allows you to dynamically load parts of your theme while still serving the user with the cached version of the page. You will need to know your way around Magento to figure this out, but here is a good tutorial on Hole Punching.

What Are You Waiting For?

Lightspeed is the number one extension we install for our clients. The longer you wait to improve your Magento performance, the longer your customers wait for your product and category pages to load on Magento!

Install Magento Lightspeed


What’s New in Magento 1.7 Community Edition

1178-blogHD-Main-670x220-2

Great news, everyone! Magento 1.7 is finally here after a long wait. Here are some of the popular new features for the Community Edition:

Generate Coupon Codes Automatically

This is a long requested feature of Magento. If you ever wanted to generate coupons with a random letter/number then you had to either write your own extension or buy a 3rd party one. Now you don’t have to worry about that. You can now create a list of coupons dynamically by defining how many you want and how you want them formatted. You can also specify a prefix and suffix so you can completely customize the way the coupon looks.

Custom Layered Navigation Pricing Steps

Magento has a lot of great features that allow you to sort products in any given category by selecting pre-defined attributes. One of those is Price. Before you had to rely on an algorithm created by Magento to determine the price steps. The problem with this is that the algorithm never worked properly. If you had 10 items between $0 and $100 and one item that was $450, you would see big gaps between the price sorting such as $0-$100, $100 – $500. Now you can customize this so you can set the prices like so: $0-$25, $0-$50, etc. That makes it a lot easier for your customers to narrow down their search for items within their budget range. Make sure you’ve added the query strings used in the price navigation to your robots.txt to help with your Magento SEO.

Customer Group Pricing

Now you can have specific prices for each item depending on the group that customer is in. Before you had to do this through Shopping Cart Price rules. This feature is a huge addition for those with multiple customer groups.

New API

The current Magento API is awful. The original SOAP API is miserably slow, and the V2 API is better but lacks documentation. The new API follows REST and uses the OAuth protocol. Now you can extend your Magento installation with ease using common sense API calls. It looks like this release is limited but they plan on adding more functions in the future.

Backup and Rollback Your Store

This has to be the best new feature available in Magento 1.7. If you’ve ever had to upgrade Magento, then you know how much it sucks (unless you’ve followed our helpful tips on upgrading). This new feature doesn’t really help with the upgrade process, but it will help if you happen to mess up your store while upgrading. You have the option of backing up just the database, just the media (product images, etc.), or just the files – or ALL OF THE ABOVE. I haven’t had a chance to test this feature so make sure you test it out before relying on it.

Overall, the new Magento is packed with some killer features. You can read all of the release notes here.


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)


How to Fix Magento Upgrade Error: SQLSTATE[23000]: Integrity constraint violation

This error is very common when upgrading Magento. We recently came across it when upgrading a client from 1.5.0.1 to 1.6.2.0 but it can happy for any version. The error typically looks like the following:

SQLSTATE[23000]: Integrity constraint violation:

To fix it, first try clearing your cache and try loading your site so the upgrade process can restart. If that doesn’t work, you need to update the initStatements in app/etc/config.xml. Change:

<initStatements>SET NAMES utf8</initStatements>

to

<initStatements>SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;</initStatements>

That should do the trick. Make sure you change it back once the upgrade is done. If you’re still having problems, check out our tips for upgrading Magento. If that doesn’t help you, leave a comment and we’ll try to point you in the right direction


Tips for Upgrading Magento

Magento-Logo

If you’ve spent any time working with Magento, you know that updates can be a real pain. We recently performed an upgrade for a client going from version 1.5.0.1 to 1.6.2.0. After spending an entire day trying to work through all of the errors, we finally got it working. We spent hours searching the Magento Forums, Stack Overflow, and Google for answers to any and every problem that we had during the process. Fortunately, a lot of the issues were common but there were a few that were unique to our situation. To make things easier for everyone, we’ve put together this list of things that you can try if the upgrade isn’t working.

Ideally, you will do these things before you start the upgrade process. You shouldn’t be performing the upgrade on a production server, so these tips are given under the assumption you haven’t started the upgrade or have the ability to start over should something go wrong. Always perform a back up of the files and database before starting an upgrade.

Disable the Cache and Clear it

This is a no-brainer. Magento is very resource intensive so it tries to cache anything and everything. Login to the admin and go to System > Cache Management. Select all items and choose “Disable” from the drop down menu.

Enable the Default Theme

If you’ve developed a custom theme for Magento, you will almost certainly run into problems when upgrading. In the admin, go to System > Configuration > Design and update your theme to use the Default templates.

Disable ALL Community Modules

This step is one that can be easily overlooked. Head to System > Configuration > Advanced > Advanced and disable all extensions that don’t start with “Mage”. Another way to do this is to open up app/etc/modules and edit each file by changing the <active></active> attribute from true to false. Once you’re done with the upgrade, enable them one by one to test and see if any specific module causes any problems.

Update the initStatements in app/etc/config.xml

There’s a 99% chance you’re going to get an error that looks like this:

SQLSTATE[23000]: Integrity constraint violation:

To fix this, open up app/etc/config.xml. You’re going to change the <initStatements> from this:

<initStatements>SET NAMES utf8</initStatements>

to

<initStatements>SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;</initStatements>

Double Check Customization to Magento Core in app/code/local/Mage

If you’ve made changes to the Magento Core files, you hopefully did it by copying the files to app/code/local/Mage instead of modifying them in app/code/core/Mage. The problem with this method is that it can potentially break your Magento installation if those core files are upgraded. There’s a good chance you won’t remember any changes you made to the core files so it’s best to just delete (backup first) app/code/local/Mage before you start the upgrade. We spent hours trying to figure out some upgrade problems when it was our customizations that were creating a bottleneck with the process.

Once you’ve finished the upgrade, make sure you clear var/cache and var/session.

Hopefully some of these tips will save you some time and prevent some nasty headaches that Magento is known to cause.


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