user permission batch clarification

42 views
Skip to first unread message

Chris Harrington

unread,
Sep 8, 2015, 9:32:06 PM9/8/15
to Google Analytics Management API
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtUserPermissions#batching

Doc says "Group your API request by user". And the sample creates a separate batch for each user. But then doc says "only batch requests for one account". So this obviously needs clarification. Can we only batch for distinct user/account combinations? If so, the doc should say "Only batch requests for one distinct account and user.". If not, why does the sample create a separate batch per user? Does it perform better than a batch with multiple users? I'd assume it would still perform better than making multiple requests.

Chris Harrington

unread,
Sep 8, 2015, 10:07:47 PM9/8/15
to Google Analytics Management API
I did a test and found that I could include multiple users in a batch. So I'm still interested in know what "Group your API request by user" means.

Matthew Cohoon

unread,
Sep 8, 2015, 10:16:18 PM9/8/15
to Google Analytics Management API
Hi Chris,
Thanks for writing in. It is matter of tradeoffs and subtile optimizations after a certain point. Just batching vs not batching you will see a huge payoff, and to optimize further group the modifications within a batch request by user, not property or profile.
Never put more then one Google Analytics account user permission update in a batch request, this will fail.

Basically it boils down to how many profiles or properties are you updating?

if you have 3 users and 10 profiles, by all means it will best to put all the requests into one batch request. just be sure group by user 
user/ account/ property/ profile
sue xxxx UA-xxxx-1 ga:1
sue xxxx UA-xxxx-1 ga:2
...
sue xxxx UA-xxxx-1 ga:10
ali xxxx UA-xxxx-1 ga:1
ali xxxx UA-xxxx-1 ga:2
...
ali xxxx UA-xxxx-1 ga:10
liz xxxx UA-xxxx-1 ga:1
liz xxxx UA-xxxx-1 ga:2
...
liz xxxx UA-xxxx-1 ga:10

If you have more then 300 changes you will need to split up the requests somehow. and if you optimize for users first it will be more efficient.

The overhead of splitting up each user into a separate batch request will probably be greater then the payoffs you get by grouping by user if you are doing a smaller number of updates. The example didn't really specify how many requests were being made so that could probably be clarified.
-Matt


On Tue, Sep 8, 2015 at 6:32 PM, Chris Harrington <back...@gmail.com> wrote:
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtUserPermissions#batching

Doc says "Group your API request by user". And the sample creates a separate batch for each user. But then doc says "only batch requests for one account". So this obviously needs clarification. Can we only batch for distinct user/account combinations? If so, the doc should say "Only batch requests for one distinct account and user.". If not, why does the sample create a separate batch per user? Does it perform better than a batch with multiple users? I'd assume it would still perform better than making multiple requests.

--
You received this message because you are subscribed to the Google Groups "Google Analytics Management API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-mana...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Harrington

unread,
Sep 8, 2015, 11:11:55 PM9/8/15
to Google Analytics Management API
Hi Matt,
Thank you for that clarification. My take away is that we may as well batch everything as long as there are <300 updates for a single account. If there are >300, then we need to detect that, and then split into batches of 300.
 - Chris
To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-management-api+unsubscribe@googlegroups.com.

Chris Harrington

unread,
Sep 9, 2015, 3:07:14 PM9/9/15
to Google Analytics Management API
Hi Matt,
Can you batch delete operations? What would that look like in Python or at protocol leve?

 - Chris

On Tuesday, September 8, 2015 at 10:16:18 PM UTC-4, Matt wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-management-api+unsubscribe@googlegroups.com.

Matthew Cohoon

unread,
Sep 9, 2015, 5:09:33 PM9/9/15
to Google Analytics Management API
Yes, the delete operation works just like any other request, in python:

  # Caution the following code will delete (almost) all profile user links!
  links = analytics.management().profileUserLinks().list(
      accountId='123456',
      webPropertyId='UA-123456-1',
      profileId='7654321',
  ).execute()
  link_ids = [item.get('id') for item in links.get('items', [])]
  batch = BatchHttpRequest(callback=call_back)
  for link_id in link_ids:
    if link_id != MY_LINK_ID: # Sanity check.
      delete_request = analytics.management().profileUserLinks().delete(
          accountId='123456',
      webPropertyId
='UA-123456-1',
      profileId
='7654321',
      linkId
=link_id
  )
      batch.add(delete_request)
  batch.execute()


I don't know exactly what would happen if you deleted your own profile filter link within a batch operation. I imagine that the remaining requests would begin to fail.
-Matt

To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-mana...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Analytics Management API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-mana...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages