You’ve probably played around with the Default Page setting in Google Analytics. In many cases, this is definitely the way to go, as it will prevent your home page from showing up in different ways in your Google Analytics reports (as / and /index.html for example).
But you need to be careful when you set the default page, as it will not only affect your home page, but any page that ends with a forward slash (‘/’).
What do I mean by this? It’s pretty simple – if you set the default page to index.html, it will not only change any future / entries into /index.html, but if you have another page ending in /, say /blog/, it will change that to /blog/index.html too. But what if your blog’s default page is actually /blog/index.php? Well, then you have a problem.
If you have several such subdirectories or pages, then you have several problems. The good news is that there is a simple way to create a simple filter that only replaces the home page.
First, you should check and see if you need it – as in many cases simply setting the default page will work just fine. There are two ways to check:
1. If you have already set your default page in Google Analytics, go to your Top Content report. Enter in your default page name into the search bar at the bottom of the report and click Go. If you see any other entries here other than your home page, make sure they are actual pages on your site, and not things that were incorrectly changed by your filter (like the /blog/index.html example above). You can simply click on the ‘View this Page’ button next to the page name if you’re not sure, and that should give you a good idea. If any of these are incorrect, you may want to use the filter below.
2. If you do not yet have your default page set, you still want to head over to the Top Content report. In the search field, enter in /$
This is a regular expression that will look for any pages that end in a forward slash. Take a good look at the list that appears and see if the default page should be the same for each one. If it is not the same, then you’ll want to leave the default page blank, and use the filter below.
So let’s get to the filter. It’s a simple Search and Replace that looks for the blank slash and replaces it with your home page name. That’s it.
Here it is:
This filter will only replace blank slashes. You need to make sure that you replace /index.html from the example here with whatever the real name of your home page is.
If you have other pages that require this kind of attention, you’ll have to change the filter pattern as well. So, using the blog scenario from above, I could create another Search and Replace filter, use ^/blog/$ as the filter pattern and then /blog/index.php as the replacement.
UPDATED 12/14/2007
Originally, I had made the error of saying you could use the same Search and Replace Filter to achieve the above affect for multiple pages at once by simply changing the filter pattern. I’m not sure where my head was at when I wrote that, but it was decidedly not correct, and was pointed out below by Justin and David (thanks for catching this). To make up for that error, here’s the Advanced Filter you would need to add a default page for multiple entires with a single filter.
The following Advanced Filter will look for entires that are /, /sub1/, and /sub2/, and append a default page name (index.html) to the end so they become /index.html, /sub1/index.html, and /sub2/index.html:
Sorry about the error, but hopefully this correct Advanced Filter makes up for it. Thanks again to those who commented on this for keeping me on my toes!
END OF UPDATE
So feel free to be creative, and keep that data clean!
Please leave a comment if you have any questions about these filters, or why you might want to think about using them. Thanks for reading!