Upcoming LunaMetrics Events
San Francisco, Apr 28-30 Los Angeles, May 12-16 New York City, May 19-23 Chicago, Jun 16-18

Filtering out traffic that is not from your website

It sometimes happens that someone will accidentally use your GA Web Property ID (UA-xxxxx-y) in their website.

When this happens, pageviews and visits from their website will show up in your GA reports.

To prevent this, you can create a filter and apply it to your main profiles.
Include hostname filter

The screenshot shows the use of a Custom -> Include filter on the Hostname field.  This example is for the site cats.com.

We are only including pageviews that happen on a domain that matches the regular expression “cats.com”.  This will match all of your subdomains such as my.cats.com or pictures.cats.com.

Website spanning multiple domains:

If you have a website that spans multiple domains such as cats.com and mycats.com and bluecats.com, then instead of filtering on “cats.com” you simply list all your domains, separated by a pipe:

Instead of:

cats.com

use:

cats.com|mycats.com|bluecats.com

Note:
If you have a profile that doesn’t have any filters on it, for raw data and troubleshooting, make sure you don’t add this filter to that profile.

http://www.lunametrics.com/blog/2010/06/01/filter-by-hostname/

6 Responses to “Filtering out traffic that is not from your website”

Alex says:

Thanks for sharing website spanning details with us.

Mariusz says:

I also use this filter although there is small probability of such a situation:) Another solution istead of pipe is in my opinion regular expression:]

Awesome things here. I am very happy to see your post. Thank you so much and I’m taking a look forward to contact you. Will you please drop me a mail?

Brent says:

Thanks, John. I have set up this filter, but it appears that when this filter is in place, I am no longer getting keyword info from my Google Adwords campaigns.

Here is the situation:

My client has 4 domains:
http://www.maindomain.com
maindomain.mobi
http://www.productdomain.com
http://www.secondproductdomain.com

Each of these was originally set up as a separate property for his account (UA-XXXXXX-1, UA-XXXXXX-2, UA-XXXXXX-3 and UA-XXXXXX-4, respectively).

Now there is a need to have a consolidated view of all 4 properties. So I set up a property of UA-XXXXXX-5 and have the asynchronous code on each page of each domain with the original property ID and setDomainName adjusted accordingly (but never using the www):

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-3']);
_gaq.push(['_trackPageview']);
_gaq.push(['b._setAccount', 'UA-XXXXXX-5']);
_gaq.push(['b._setDomainName', 'productdomain.com']);
_gaq.push(['b._setAllowLinker', true]);
_gaq.push(['b._trackPageview']);

(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’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

I also created 5 profiles in this property–one for the consolidated view with the only filter being:

Filter Type: Custom filter > Advanced
Field A: Hostname
Extract A: (.*)
Field B: Request URI
Extract B: (.*)
Output to: Request URI
Constructor: $A1$B1

The other 4 profiles have this same filter plus the one you outlined above so I can see traffic specific to each site.

Filter Type: Custom filter > Include
Filter Field: Hostname
Filter Pattern: productdomain\.com
Case Sensitive: No

In each of the profiles in UA-XXXXXX-5, I have set up the same goals that exist in the original profile, but this time I include the domain in the Goal URL for my URL destination goals.

Everything seems to be working fine (i.e. what I see on the original property matches what I see on the corresponding profile in the consolidated property) except for one thing. In the original property I see the actual keyword for clicks coming from Google Adwords but in the corresponding profile in the consolidated property, the keyword for that same click is “(not set)”. The keywords come through fine for their Bing PPC, just not for Google. In standard reporting, I am using the Traffic Sources > Search > Paid view.

Note: I can see the keywords in the consolidated view profile that does not have your filter but not in the 4 site-specific profiles that contain your filter.

The destination URLS for both the Bing and Google paid ads are exactly the same using the format http://www.productdomain.com/(landing page url if applicable)?acqkw=[keyword]&acqmt=[match type]&acqcmpgn=[campaign name]

Do I need to make an adjustment to the filter you describe above to make sure I get the keywords? If not, do you have any other ideas?

Thanks!

Brent.

Brent says:

John,

I found the answer to my question. To get the keyword information included from AdWords campaigns, the box “Apply Cost Sources” in the profile settings must be checked. I assume that the linkage with the AdWords account must have already been made, too, but I didn’t test for that.

So you can publish or not publish my comments. But I do appreciate you giving information on setting up this filter.

Thanks.

Brent.

Liz Madeley says:

Hi John, thanks for writing this up, but did you forget to escape the dots? Shouldn’t cats.com be cats\.com ? If not,let me know, would be interesting to find out.