Google Analytics: Filtering URI But Not Events Sent Together

Another off-topic post on stackoverflow.com asks:

Google Analytics: Filtering URI But Not Events Sent Together

I need to filter out some URI from Google Analytics (beucase I send some custom pageviews on these pages instead), but not the events sent together on these pages.

Frankly in that case I would not send any pageviews at all, just the events. But if for some reason you need to do this you can use a sequence of two filters.  Two because you cannot simply filter by the page path or request Uri (because that will be the same for pageview and event), so you need to mark the pageview for deletion first and then remove it. The way to do this is to look at the hit type:

Mark pageview for deletion

This inspects the hit type and if it’s a pageview stores the hit type in a variable (that’s what the parenthesis are for). Then we do the same for the URI we want to filter out.  If now  both custom variables contain a value we set a custom page title that marks this pageview for deletion, which is then done via a second filter:

Delete

This looks at the page title, and if it matches the custom title set in the previous filter the pageview is removed. The event sent at the same time is not affected since it has another hit type.

Realtime view will still display a pageview with the event (I guess because a page path is sent with every event), but in a quick test this filter combo produced a number of  events without a corresponding pageview, so I guess this did what the OP was asking:

Result

As I said I’m not quite sure what the point of this would be, but it seems to work, and at least it made me notice the hit type filter field which I was previously unaware of.

Leave a Reply

Your email address will not be published. Required fields are marked *