Server Integration With Google Analytics
In this tutorial, I will mention step by step process to implement integration with Google Analytics or any google product through APIs.
In this example, I will specifically integrate Google Analytics with NodeJS.
- Should have Google Analytics account
- Should be added to any website to track some data and get them in APIs.
See my previous post Adding Google Analytics To Your Website to setup everything if not done yet.
Steps to create a server key from Google
- Go to Console Cloud
- Create a new project.
- Enable Google Analytics Reporting API for this project specifically.
- Once reporting API is enabled, create a new server key under credentails
- Download this server key in JSON format file. This file looks like this.
- The last step is to create a user on Analytics with server key information. Under your Admin > your property > User Management, create a new user with client_email mentioned in server key.
Once all steps are done, you are ready to implement your integration.
NodeJS Example Code for integration
There is a good way to create and test your request before implementing it in your actual code by using Request Composer provided by Google. You can create your actual request APIs specific to your business here and see your response results as well.
In case of any questions/concerns, please feel free to leave a comment below.
Happy Coding ;)