好的,我正在尝试以编程方式将过滤器添加到Google Analytics分析视图中。谷歌指南推出:
本指南介绍如何插入过滤器。但是此过滤器是在帐户级别创建的,然后您需要将其添加到特定视图。如何将其添加到视图中?
答案 0 :(得分:1)
您需要创建profile filter link:
# Note: This code assumes you have an authorized Analytics service object.
# See the Filters Developer Guide for details.
# This request creates a new profile filter link.
try:
analytics.management().profileFilterLinks().insert(
accountId='123456',
webPropertyId='UA-123456-1',
profileId='7654321',
body={
'filterRef': {
'id': '1223334444'
}
}
).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))