Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics API: filter by URI?

My site has user profiles that are accessible via URLs that look like this: www.domain.com/profile/123/.... I want to show users page view statistics of their profiles, but need to be able to do wildcards.

For example, this works:

filters=ga:pagePath==/profile/123/

The problem is that there are potentially other URI segments that follow /profile/123/. I want to do something like this (does not work):

filters=ga:pagePath==/profile/123/*

Suggestions?

like image 358
StackOverflowNewbie Avatar asked Nov 22 '10 11:11

StackOverflowNewbie


People also ask

Can you filter by state in Google Analytics?

You can also track data from smaller geographical regions such as specific cities, states, or individual countries. To view statistics from these types of regions, use the following Include filter: Filter Type: Custom filter > Include. Filter Field: City (you can also use Region or Country)

What are the 2 types of filters in Google Analytics?

Search & Replace: This is a simple filter that you can use to search for a pattern within a field and replace the found pattern with an alternate form. Advanced: This type of filter allows you to build a field from one or two other fields.


2 Answers

Use the 'Contains a match for the regular expression' operator (~) from the Dimension Filters.

filters=ga:pagePath=~/profile/123/* 
like image 120
Yahel Avatar answered Oct 30 '22 14:10

Yahel


This will work:

 filters=ga:pagePath=~/profile/123/

To do /*/view/* (as per @VinnyG’s comment), this should work:

filters=ga:pagePath=~/[^/]+/view/

I'm assuming you want to match one (and only one) directory before /view/.

like image 44
s6mike Avatar answered Oct 30 '22 13:10

s6mike