Google Analytics - 通过服务帐户访问自定义细分 [英] Google Analytics - Access custom segments through Service Account

查看:115
本文介绍了Google Analytics - 通过服务帐户访问自定义细分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要从后端服务器获取Google Analytics数据。

My application needs to fetch Google Analytics data from backend servers.

我在我的应用程序中使用Google服务帐户。
尽管我已通过Google Developer Console向服务帐户授予所有权限,但事实证明,我的服务帐户无法访问我的用户帐户的自定义细分。

I am using Google Service Account in my application. Though I have given all permissions to my service account through Google Developer console, it turns out that my service account cannot access custom segments of my user account.

一种方式可能是将用户帐户中的这些段复制到服务帐户,但似乎无法通过服务帐户登录,并且能够将用户帐户中的段复制到服务帐户。

A way could have been to copy these segments from user account to service account, but there seems like no way to login via service account and be able to copy segments from user account to service account.

所以,似乎无法从后端获取Web应用程序中的自定义段...

So, there seems like no way to be able to fetch custom segments in a web application from backend...

有没有办法做到这一点?
任何其他帐户(网络应用程序,已安装的应用程序帐户)是否可以满足我的目的?
阅读上述两个Google帐户的文档可以发现,在这两个帐户的授权过程中,系统会提示用户进行身份验证(至少一次),这在后端服务器中不可行。

Is there any way to do so? Can any other account(web application, Installed application account) serve my purpose? Reading the documentation of above two Google accounts reveals that user would be prompted for authentication (at least once) during authorization in these 2 accounts which is not feasible in backend servers.

我为我的查询找到了类似的线索 Google Analytics(分析)V3 - 如何为API服务帐户创建自定义细分市场,但此线程中的用户根本不使用细分市场,但我确实需要在我的帐户中使用它们。

I found a similar thread for my query Google Analytics V3 - How to create custom segments for API Service Accounts , but user in this thread resorted to not using segments at all, but I do need to use them in my account.

PS:我正在使用RubyOnRails编写我的应用程序,并且将使用Ruby Gem进行Google身份验证。

PS: I am writing my application in RubyOnRails and would be using Ruby Gem for Google Authentication

推荐答案

答案:否,没有办法将分段添加到服务帐户。即使是分段API也只允许你列出不添加它们的分段。 细分管理API 文档

Answer: No there is no way to add segments to the Service account. Even the Mangment api only allows you to list segments not add them. Segment Management API documentation

一个想法:您可以使用我们的正常Oauth2使用您的帐户进行身份验证,将刷新令牌保存在某个位置并在您的应用程序中使用它来查看数据。那么它就像应用程序永远是你,并能够看到你的细分市场。

An Idea: You could us normal Oauth2 Authenticate it using your account, Save the refresh token someplace and use that in your application to see the data. Then it would be like the Application is always you and would be able to see your segments.

对不起,我不知道红宝石,所以我无法帮助您解决这个问题。

Sorry I don't know ruby so I cant help you with getting the idea working.

这篇关于Google Analytics - 通过服务帐户访问自定义细分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆