Get Source and Medium from ga.js

半城伤御伤魂 提交于 2019-12-23 22:51:40

问题


I have a newsletter page on my website which I'd like to also use to capture some additional information about the user using Google Analytics.

Using the getAll() method from ga.js I can get the referrer URL (if any), however I cannot see the medium or source data. Is this possible to retrieve using their ga.js library?


回答1:


Retrieve specific tracker from the list of trackers you obtained. Use the following to access the fields source and medium. tracker.get('campaignSource') and tracker.get('campaignMedium')

Additional help from below links. Access data from ga object: https://developers.google.com/analytics/devguides/collection/analyticsjs/accessing-trackers

Field reference: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference




回答2:


If you are using google analytics core reporting api try this 'metrics': 'ga:sessions ,ga:pageviews', 'dimensions' : 'ga:source,ga:medium'



来源:https://stackoverflow.com/questions/47752099/get-source-and-medium-from-ga-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!