firesphere / google-api
连接到Google Analytics API以获取页面访问量
Requires
- php: >=5.6.0
- google/apiclient: ^2.0
- silverstripe/recipe-cms: ^4.0
Requires (Dev)
README
Google API
Google API V4功能强大,支持多种不同应用程序的多种调用。
该模块实现的基本用例是,在给定时间段内获取一组页面的页面浏览量,并将此计数存储在数据库中,以便您可以按受欢迎程度对页面进行排序。Google API具有许多功能,可能包含在未来模块更新或扩展中。
使用提供的API可以实现更多功能
安装
composer require firesphere/google-api:dev-master
然后运行 dev/build
设置
首先,您需要设置一个与Google Analytics连接的Google API应用程序。如何设置请参阅 Google 文档。
将密钥的绝对路径添加到您的 _ss_environment
文件中
define('SS_ANALYTICS_KEY', 'name-of-my-file');
目前,OAuth2集成尚未构建,因此目前请添加从下载的json文件中获取的电子邮件地址(键:client_email),并将此用户添加到您的Analytics账户。您需要授予它完整的行政权限。
其次,从您希望获取数据的Google Analytics账户中复制您的 视图ID
,并将其放在CMS的设置 > Google API 下
配置
创建一个yml文件,或将配置添加到现有的config yml,以进行更新
GoogleAnalyticsReportService: begins_with: '/mypage' # Find everything Google knows about children of this page. Can not be used in combination with other configurations ends_with: 'mypage' # Find everything Google knows about pages whose URL end with 'mypage', Can not be used in combination with other configurations whitelist: # Array of pagetypes you want to search for. Can be combined with blacklist - MyPageType - MyOtherPageType blacklist: # Exclude these pagetypes from being returned - MyBlacklistedPage - MyOtherBlacklistedPage
使用多个过滤器时,Google似乎仅限制前20个过滤器。
如果您有多个过滤器,则需要设置批处理功能。默认情况下,CronTask会为您完成此操作。
当前,Crontask不支持计划,但将来可能会支持。
过滤器是Google所说的“DimensionFilters”,它们包含在“DimensionFilterClause”中。在这个阶段,过滤器是一个特定的页面URL。
更多关于 DimensionFilterClauses和DimensionFilters的信息可以在Google文档中找到。
你是在说忍者独角兽吗?
/
.7
\ , //
|\.--._/|//
/\ ) ) ).'/
/( \ // /
/( J`((_/ \
/ ) | _\ /
/|) \ eJ L
| \ L \ L L
/ \ J `. J L
| ) L \/ \
/ \ J (\ /
_....___ | \ \ \```
,.._.-' '''--...-||\ -. \ \
.'.=.' ` `.\ [ Y
/ / \] J
Y / Y Y L
| | | \ | L
| | | Y A J
| I | /I\ /
| \ I \ ( |]/|
J \ /._ / -tI/ |
L ) / /'-------'J `'-:.
J .' ,' ,' , \ `'-.__ \
\ T ,' ,' )\ /| ';'---7 /
\| ,'L Y...-' / _.' / \ / /
J Y | J .'-' / ,--.( /
L | J L -' .' / | /\
| J. L J .-;.-/ | \ .' /
J L`-J L____,.-'` | _.-' |
L J L J `` J |
J L | L J |
L J L \ L \
| L ) _.'\ ) _.'\
L \('` \ ('` \
) _.'\`-....' `-....'
('` \
`-.___/
许可证
BSD-3条款