Mobile app version of vmapp.org
Login or Join
Kristi941

: Can I programatically update a Google Analytics filter? We have a constantly changing list of IPs that needs to be filtered out of google analytics, is there some API, or way to fetch the

@Kristi941

Posted in: #AnalyticsApi #GoogleAnalytics

We have a constantly changing list of IPs that needs to be filtered out of google analytics, is there some API, or way to fetch the list of IPs to be included in a Google Analytics filter?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Kristi941

2 Comments

Sorted by latest first Latest Oldest Best

 

@Merenda212

You can now do this as part of their Google Analytics Management API.

Example in Python

# Note: This code assumes you have an authorized Analytics service object.
# See the Filters Developer Guide for details.

# This request creates a new filter.
try:
analytics.management().filter().insert(
accountId='123456',
body={
'name': 'My Domain Filter',
'type': 'EXCLUDE',
'excludeDetails': {
'field': 'GEO_DOMAIN',
'matchType': 'EQUAL',
'expressionValue': 'example.com',
'caseSensitive': False
}
}
).execute()

except TypeError, error:
# Handle errors in constructing a query.
print 'There was an error in constructing your query : %s' % error

except HttpError, error:
# Handle API errors.
print ('There was an API error : %s : %s' %
(error.resp.status, error.resp.reason))

10% popularity Vote Up Vote Down


 

@Turnbaugh106

Sadly, no , although this would be a great feature though. The best thing you can do is block ranges of IP, you can do this with the following format:-

192.168.0.1 to 192.168.0.255


Regex's to

^192.168.0.([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$


Google have an IP range generation tool to help you out with this.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme