The ROI Revolution Blog

« Funny Adwords Contest: Round 2 | Main | Goal Matching Revisited »

Default Page vs. Home Page

December 12, 2007

Crystal_Clear_app_kfm_home.pngYou'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:

home-page-filter-small.gif

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:

advanced-default-filter-sma.gif

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!


Interested in learning more about Google Analytics?
Attend our LIVE Google Analytics Seminars for Success training in Atlanta, GA Wednesday, April 14th, 2010 and Thursday, April 15th, 2010 or get the latest tips and tricks sent to you via our free, twice-monthly Google Analytics newsletter.

Comments

Justin said:

Hey Shawn,

Great post. I think there may be an issue with your search and replace filter. If memory serves me right, the search and replace filter will replace the entire filter field. So, in the example you give, the entire Request URI will be replace with /index.html regardless of which pattern is matched. So if the Request URI is /sub1/ that entire value will be replaced with /index.html not /sub1/index.html.

I'm pretty sure that's the way search & replace filters work... but Google may have changed them on us. Gotta love those unannounced changes!

I believe the correct solution is to use an advanced filter to capture the appropriate part of the request URI and combine it with the appropriate default page name.

Let me know if I'm way off on this one...

Justin

December 13, 2007 11:37 AM

David Burke said:

Can you provide an example of the "multi-replace" filter?

Wouldn't

^/$|^/sub1/$|^/sub2/$

replace

/, /sub1/, and /sub2/

with just /index.html?

How are the sub-folders preserved when doing the replacement?

December 14, 2007 12:34 AM

Shawn Purtell, Google Analytics Support Tech Author Profile Page said:

Justin,

No, you're right about this one. I think I was in too much of a hurry to publish and got some of my mental wires crossed. Thanks for catching this. Although the original home page filter in the post is correct, I'm updating the post to contain the Advanced Filter you would need to use to replace multiple pages at once.

Thanks for reading.

December 14, 2007 9:22 AM

Shawn Purtell, Google Analytics Support Tech Author Profile Page said:

@David:

Good catch. I'm updating the post to contain the Advanced Filter you would need to accomplish the task. Thanks for pointing this out.

December 14, 2007 9:24 AM

David Burke said:

Hi Shawn,
Thanks for the update! This is great information.

One other situation comes to mind, but would require using .* as part of a regular expression. From what I've read, Google suggests avoiding the use of .* as it "may slow down processing the expression."


The sitation is this: I've got a "regular site" with a WordPress blog installed. Anywhere from the blog parent folder on down a URL ending in / would map to /index.php So /blog/sub1/, /blog/sub1/sub2/, /blog/sub1/sub2/sub3/ would all need "index.php" appended.


Can the Advanced filter be set up like:

Field A -> Extract A  Request URI  ^/blog.*/$

Output to Constructor  Request URI  $A1index.php

Or is using .* in the regular expression going to cause problems?

December 14, 2007 7:12 PM

Shawn Purtell, Google Analytics Support Tech Author Profile Page said:

@David:

Glad you found the new information useful. Sorry for screwing it up the first time.

Anyway, to answer your question, you were close. You just need to put parentheses around the whole thing, so that it will be stored in the variable $A1, like this:

(^/blog.*/$)

Everything else looks fine. I don't think adding the .* is going to cause problems in this case.

December 17, 2007 2:22 PM

alder said:

Can we add GA code in .info sites??????

December 31, 2007 7:52 AM

Shawn Purtell, Google Analytics Support Tech Author Profile Page said:

@alder:

I don't see why not, although I haven't personally set up Google Analytics on a .info site. As long as the user's machine can process the Google Analytics javascript code on the site, there should be no problem.

January 2, 2008 9:31 AM

Jason Joyce said:

Hi,

I'm trying to search and replace plus symbols & %20 within search terms to underscores as its easier to read.

ie.

Change this (this%20is+my+phrase)

To This (this_is_my_phrase)

But the filter I've used only replaces the first occurrence.

(\+|%20)

Would you know any solutions?

October 31, 2008 8:06 AM

Shawn Purtell, Google Analytics Support Tech Author Profile Page said:

@Jason:

Well, the quick and dirty way is to use multiple filters. For example running two of those filters one after the other would remove the first 2 instances. You can run 3 or 4 to be sure.

Other than that, there are some more complicated ways you could do this with Advances filters, or you can rewrite the data before it gets sent to Google Analytics. If you're looking for a quick fix though, I'd just use multiple filters.

Hope that helps!

October 31, 2008 8:32 AM

Megan said:

I'm hoping this will help combine my / data with /default.html data so I get more accurate info on homepage traffic. Will this filter fix that problem? Just setting my homepage has not fixed that. For instance, in Top Content, I see / has a row of data, and /default.html has a whole nother row of data (several rows down - less popular). I did the custom filter and don't yet see results (combined data in Top Content) but maybe it's starting this business from here forward (not retroactive). -hopeful

November 8, 2008 3:40 AM

Shawn Purtell, Google Analytics Support Tech Author Profile Page said:

@Megan:

Your setting/filter has probably worked, but as you guessed, it does not get applied retroactively. As with most settings within Google Analytics, the changes will only affect data moving forward. You should be seeing different results since you started using the filter. Thanks for reading!

November 17, 2008 7:53 AM

Richard said:

Does this filter only work for 2 sub directories?

I see that you have sub1 and sub2 but what if I have a directory that goes 6 directories deep? Some of my directories might go even deeper but all the pages are index.php I rather see them as dir/ instead of dir/index.php

IS that possible. Thanks for your help. I am alittle lost.

February 27, 2009 12:07 PM

Shawn Purtell, Google Analytics Support Tech Author Profile Page said:

@Richard:

You can use the filter for as many subdirectories and levels of subdirectories that you need. You just need to change the part of the Advanced filter that looks like this:

(^/$|^/sub1/$|^/sub2/$)

If you want to include multiple levels, say /sub1/secondlevel/, you could do this:

(^/$|^/sub1/secondlevel/$|^/sub2/$)

If you want to do more that three, you simply use the pipe ('|') character, like this:

(^/$|^/sub1/$|^/sub2/$|^/sub3/$)

If you want to change all page that end in a specific subdirectory, regarless of level, remove the carot (^), like this:

(/sub1/$|/sub2/$)

If you'd rather see /dir/ than /dir/index.php, you would have to change the filter to something like this:

(.*)(/sub1/|/sub2/)index.php

output to Request URI as:

$A1$A2

This filter works in the opposite way as the ones described in this article, and will find any /sub1/index.php entries and replace them with /sub1/ and all /sub2/index.php pages and replace them with /sub2/.

Filters can get pretty complicated, but I hope this helps! Thanks for reading.

February 27, 2009 1:24 PM

Richard said:

Yes you are right. It can be very confusing. So I think I am a bit confused (go figure). Do I need to create one filter for each depth of folder? For instance,

I have my site like this

Category/SubCat/SubCat/SubCat/Item/

Each folder might have more sub directories. Each folder also has a index.php in it.

Is there a way for it to globally just process the whole site in the /category/ folder just looking clean without the index.php?

I am sorry but I am wondering if there is more automatic way of doing this.

The links on my site are only directories like http://www.domain.com/category/sub/

instead of them using
http://www.domain.com/category/sub/index.php

I think google anylitics is counting that as a bounce since it see's the page as index.php not http://www.domain.com/category/sub/

Thanks so much for your help.

February 27, 2009 3:03 PM

Shawn Purtell, Google Analytics Support Tech Author Profile Page said:

@Richard:

Yes - you can use the following filter:

Type: Custom - Advanced

Field A -Extract: (.*/category.*/)index.php

Output to - $A1

This will take any page that is part of the /category/ subdirectory that has index.php (no matter the level) and strip it out.

In other words it will take:

http://www.domain.com/category/sub/index.php
http://www.domain.com/category/sub/sub2/sub3/sub4/index.php

And replace them with:

http://www.domain.com/category/sub/
http://www.domain.com/category/sub/sub2/sub3/sub4/

I don't think any of this naming would affect your bounce rates. Bounce rates are unaffected by the page title that's showing up in Google Analytics.

As a side note, if you have important query parameters on these pages you need to keep, you'd change the following parts of the above filter:

Field A -Extract: (.*/category.*/)index.php(.*)

Output to - $A1$A2

This will change a page like:
http://www.domain.com/category/sub/index.php?s=43&p=232&test=1

into:
http://www.domain.com/category/sub/?s=43&p=232&test=1

Hope that helps!

March 2, 2009 8:56 AM

Post Your Comments

Feedback Form