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

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

Website spanning multiple domains:

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

Instead of:


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.

John is a former LunaMetrician and contributor to our blog.

  • Thanks for sharing website spanning details with us.

  • 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?

  • 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:

    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([‘b._setAccount’, ‘UA-XXXXXX-5’]);
    _gaq.push([‘b._setDomainName’, ‘’]);
    _gaq.push([‘b._setAllowLinker’, true]);

    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘’;
    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:
    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 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?



  • 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.



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

Contact Us.

Follow Us



We'll get back to you
in ONE business day.
Our Locations
THE FOUNDRY [map] LunaMetrics

24 S. 18th Street
Suite 100

Pittsburgh, PA 15203


4115 N. Ravenswood
Suite 101
Chicago, IL 60613


2100 Manchester Rd.
Building C, Suite 1750
Wheaton, IL 60187