Analytics
4.6K members online now
4.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

GA API and massive exclusion by using a filter.

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello.

 

I have the following problem. I want to get all the sessions with a dimensions == 'ga:networkLocation' but I want to exclude a huge amount of strings, so I do this:

(PHP):

 

  $params = array(
'start-date' => '2016-01-01',
'end-date' => '2016-03-04',
'dimensions' =>  'ga:networkLocation',
'metrics' => 'ga:sessions',
'sort' => '-ga:sessions',
'max-results' => 100 
);

 

The problem is I have this list of networkLocations, it's about 10 thousand records. What I do now is that I'm getting the list from the API, and use php to remove those which I don't want. 

 

But this is useless, because they are about 99% of all the records, so when I get 100. I'm left with 1 record I'm interested in. When I get 1000, I get 10 records, but first - it's slow, second - those 10 records is still not enough.

 

Do you have any idea? I know about the 'filters' => 'ga:networkLocation!=xyz' param, but I can't send 10'000 names to GA API Smiley Happy

 

Best regards,

Konrad.

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author konrad p
May 2016

Re: GA API and massive exclusion by using a filter.

Top Contributor
# 2
Top Contributor
Sending really long exclusion lists in the form of filters or segments to the API is almost guaranteed to cause a timeout or 500 error as the server decides it is taking too long to process your request.
Consider creating a View with View filters to exclude a large part of the network locations and then post-filter for any remaining ones (assuming you list changes over time). You can create multiple view filters, each using regex expressions, and that should significantly reduce the number of sessions in the view to a more manageable list.
Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author konrad p
May 2016

Re: GA API and massive exclusion by using a filter.

Top Contributor
# 2
Top Contributor
Sending really long exclusion lists in the form of filters or segments to the API is almost guaranteed to cause a timeout or 500 error as the server decides it is taking too long to process your request.
Consider creating a View with View filters to exclude a large part of the network locations and then post-filter for any remaining ones (assuming you list changes over time). You can create multiple view filters, each using regex expressions, and that should significantly reduce the number of sessions in the view to a more manageable list.
Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Re: GA API and massive exclusion by using a filter.

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks! I will get to this on Monday. I don't know about those filter views anything right now.

And then I'll probably accept your answer obviously.

Thanks again Mike!

Re: GA API and massive exclusion by using a filter.

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Mike, I still have issues, can you please look at this: https://www.en.advertisercommunity.com/t5/Tracking-Goals-Ecommerce/Using-view-settings-Segments-Cond... ? First I didn't find "Service provider" in those filters you suggested, so I moved to "segments" - there is does exist, but it doesn't allow me to enter too long string apparently (although does not say that clearly), and I don't know what to do.

Re: GA API and massive exclusion by using a filter.

Top Contributor
# 5
Top Contributor
Regex expressions are limited to 128 or 256 characters...can'the remember which. But you can combine multiple, regex expressions with or logic (not the | character in an expression. ..actually multiple expressions).
Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.