differences between segment and filter

973 views
Skip to first unread message

Axel

unread,
Feb 4, 2010, 4:10:55 PM2/4/10
to google-analytics-api - GA Data Export API, ax...@one4ads.com, al...@one4ads.com
Hello,

Before the arrival of segment in the API, i was used to filter my data
using the filters parameter for example : filters=ga:country==Canada

But now i'm confused about what to use in order to do that.

There is already a discussion about segment and filter here
http://groups.google.com/group/google-analytics-data-export-api/msg/72ab2987bda6937a
but in that one this is about profile filtering and not query
filtering.

So, for example I want to know how many visits went through the /
Blogs/ section.
I used to do that (use of filters = ga:pagePath=~/Blogs/) :
https://www.google.com/analytics/feeds/data?ids=ga%3A8843450&metrics=ga%3Avisits&filters=ga%3ApagePath%3D~%2FBlogs%2F&start-date=2010-01-01&end-date=2010-01-31
But, there is now another to do that (use of segment =
dynamic::ga:pagePath%=~/Blogs/ )
https://www.google.com/analytics/feeds/data?ids=ga%3A8843450&metrics=ga%3Avisits&segment=dynamic%3A%3Aga%3ApagePath%3D~%2FBlogs%2F&start-date=2010-01-01&end-date=2010-01-31

And you can try with the Data Feed Query Explorer (http://
code.google.com/apis/analytics/docs/gdata/gdataExplorer.html) on your
website and you will get two different numbers.

Can someone explain the differences to me ?

Axel

unread,
Feb 9, 2010, 2:45:29 PM2/9/10
to google-analytics-api - GA Data Export API
Hi again,

can someone help me find the differences between using the filter
parameter and the segment parameter ?

segment=dynamic::ga:country==Canada
and
filters=ga:country==Canada
gets the same results whereas...

segment=dynamic::ga:pagePath=~/company/
and
filters=ga:pagePath==/company/
gets two very different results (much more visits with the segment)

thank you for any help.

On 4 fév, 16:10, Axel wrote:
> Hello,
>
> Before the arrival of segment in the API, i was used to filter my data
> using the filters parameter for example : filters=ga:country==Canada
>
> But now i'm confused about what to use in order to do that.
>
> There is already a discussion about segment and filter herehttp://groups.google.com/group/google-analytics-data-export-api/msg/7...
> but in that one this is about profile filtering and not query
> filtering.
>
> So, for example I want to know how many visits went through the /
> Blogs/ section.
> I used to do that (use of filters = ga:pagePath=~/Blogs/) :https://www.google.com/analytics/feeds/data?ids=ga%3A8843450&metrics=...
> But, there is now another to do that (use of segment =
> dynamic::ga:pagePath%=~/Blogs/ )https://www.google.com/analytics/feeds/data?ids=ga%3A8843450&metrics=...

Nick

unread,
Feb 17, 2010, 6:04:57 PM2/17/10
to google-analytics-api - GA Data Export API
Hi Axel,

Although the syntax between the two is similar, filters and segments
fundamentally operate differently. If you haven't seen it, we created
a video that tries to explain the two: http://www.youtube.com/watch?v=7nJzwDIf7r4

For filters, when you make an API request you get back entries of data
which represent rows in a table. Adding a filter simply includes or
excludes rows of that final table.

Segments operate at a lower level. Currently Google Analytics collects
a stream of "hits" (pageviews/events/etc) which are associated with a
session. Each dimension and metric Google Analytics exposes can be
represented as a function where the parameter is all the sessions in
the selected date range. GA computes the values (dimensions and
metrics) of each function and returns the results. Adding an advanced
segment specifics which sessions should be passed to these functions.
So writing segment=dynamic::ga:country==Canada will only compute the
specified dimensions and metrics for sessions where the country was
equal to Canada. Something to keep in mind here is that advanced
segments currently only operate on sessions.

In your question above, the difference has to do with the fact that
ga:country is a session level dimensions and page path is a page (hit)
level dimension.

Since advanced segments operate on sessions,
segment=dynamic::ga:country==Canada will only return sessions (visits)
that came from Canada. And filters=ga:country==Canada will pull all
session (visit) data but only return sessions (visits) from Canada. So
they end up returning equivalent results.

Using segment=dynamic::ga:pagePath=~/company/

will return sessions that ONLY had at least one page view with a url
that matches the ~=/company/ expression. These sessions are then
passed to the dimension and metric functions and your results are
computed on the fly.

only using filters=ga:pagePath==/company/

will compute data for ALL sessions, but only the rows where the
expression matched would be returned from the request.

I hope this helps.
-Nick

Axel

unread,
Feb 23, 2010, 10:38:23 AM2/23/10
to google-analytics-api - GA Data Export API
Hello there

Thank you for the explanation. In fact, I've viewed the video just
yesterday. Anyway, i understood that i had to use the advanced segment
for my purpose here.

Bye

Reply all
Reply to author
Forward
0 new messages