# How to obtain the credentials to communicate with Google Analytics ## Getting credentials The first thing you’ll need to do is to get some credentials to use Google API’s. I’m assuming that you’ve already created a Google account and are signed in. Head over to [Google API’s site](https://console.developers.google.com/apis) and click "Select a project" in the header. ![](https://i.imgur.com/8xxGLAc.png) ![](https://i.imgur.com/1dblm1b.png) ![](https://i.imgur.com/P0WCNA3.png) ![](https://i.imgur.com/QatwG1J.png) Next up we must specify which API’s the project may consume. In the list of available API’s click "Google Analytics API". On the next screen click "Enable". ![](https://i.imgur.com/avKtoqv.png) ![](https://i.imgur.com/W7PRekf.png) Now that you’ve created a project that has access to the Analytics API it’s time to download a file with these credentials. Click "Credentials" in the sidebar. You’ll want to create a "Service account key". ![](https://i.imgur.com/RZOGDB8.png) ![](https://i.imgur.com/bfVnshN.png) On the next screen you can give the service account a name. You can name it anything you’d like. In the service account id you’ll see an email address. We’ll use this email address later on in this guide. Select "JSON" as the key type and click "Create" to download the JSON file. ![](https://i.imgur.com/oTT8Pg1.png) ![](https://i.imgur.com/RiD1Mbp.png) ![](https://i.imgur.com/5fwATiW.png) ![](https://i.imgur.com/EgGvPY0.png) ![](https://i.imgur.com/kwpclye.png) ![](https://i.imgur.com/zdA5PQh.png) You already have the JSON file. Now, you'll need to upload this file to the server through your admin page. Because the JSON file contains potentially sensitive information I don't recommend committing it to your git repository. ## Granting permissions to your Analytics property Step for new user: ![](https://i.imgur.com/aAzdFcb.png) ![](https://i.imgur.com/nUmLGDh.png) * Show advanced options and setting follow picture below. ![](https://i.imgur.com/L59skbx.png) ![](https://i.imgur.com/t6LfDX6.png) ![](https://i.imgur.com/B6zOBs3.png) ![](https://i.imgur.com/kAzQU6n.png) ![](https://i.imgur.com/i419Ryt.png) I'm assuming that you've already created a Analytics account on the [Analytics site](https://analytics.google.com/analytics). (Skip step above) Go to "User management" in the Admin-section of the property. ![](https://i.imgur.com/IVYhlmS.png) On this screen you can grant access to the email address found in the ```client_email``` key from the json file you download in the previous step. Read only access is enough. ![](https://i.imgur.com/Z48mPOB.png) ![](https://i.imgur.com/FGdH7tW.png) ## Getting the view id The last thing you'll have to do is fill in the ```view_id``` in the config file. You can get the right value on the [Analytics site](https://analytics.google.com/analytics). Go to "View setting" in the Admin-section of the property. ![](https://i.imgur.com/VwZ1WJV.png) You'll need the ```View ID``` displayed there. ![](https://i.imgur.com/goP9iOD.png) Ok! Now, add the ```View ID``` to your website management. ## Bonus: Get script to custom head Select tracking information: ![](https://i.imgur.com/sVTWiL1.png) Copy script & add to custom head throught setting general your admin page. ![](https://i.imgur.com/xtGTCc3.png)