I want to get some of the data from Google Analytics into Salesforce. I have looked through a series of articles but I couldn't find any step by step guide how to do so, hence I am unsure what approach should I take. This is one of the articles I tried to follow: https://developer.salesforce.com/page/Apex_Web_Services_and_Callouts

I would need to get the data on a daily basis so I was thinking in creating a batch class which performs GA callouts everyday. I don't have much experience in doing so, especially how to work with the GA api.

If anybody has any knowledge how to achieve this in terms of what design approach would be the easiest to implement and could lead me into the right direction or is able to provide some sample code, reference some useful articles I would be grateful.


Connect apex and Google API using JWT to retrieve Oauth 2.0 token

The comment by Andy H. gives you all the needed info to start pulling info out. I finished today my project and we're already getting GA info into our SF org thanks to his explanation on that post.

With that you can get your token, so you only have to go to https://ga-dev-tools.appspot.com/query-explorer/ and build your query, copy it adding at the end the token you got from the callout you build from the code by Andy H. And then you only have to structure the info in the Json you will receive and store it in the objects you find suitable.

Hopes this helps you, if you are still struggling I can share some of my code but most of it it's just the same than his.

| improve this answer | |
  • 1
    So basically what you're saying is, this question is a duplicate? – Adrian Larson Apr 27 '16 at 15:35
  • @Alexander Aeons Torn thanks for your answer I will look into the article you posted – Marc Zaharescu Apr 27 '16 at 15:38
  • @Alexander Aeons Torn I would require a bit of your assistance if you don't mind with regards to a couple of initial setup configurations. – Marc Zaharescu May 3 '16 at 9:26
  • Sure Mate, where do are you having doubts? – Alexander Aeons Torn May 3 '16 at 9:55
  • 1
    Let us continue this discussion in chat. – Marc Zaharescu May 3 '16 at 13:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.