- Go to the Google API Console.
- If you have not created any Google API project yet, click NEW PROJECT to create a new project. Otherwise, select a project from the projects list.
- On selecting the NEW PROJECT, you will be redirected to the project creation page. Enter the Project Name.
- A Project ID will be assigned automatically to your new project. If you want to change this ID, click the Edit link under the Project name field.
- Click the CREATE button.
- The project would be created and you would be redirected to the project dashboard.
- API & Services: Click on Enable APPS AND SERVICES
- Search Box: Type Google Analytics API
- Enable Button To Activate Google Analytics API services.
- In the left side navigation panel, select Credentials under the APIs & Services section.
Add Credentials to Your Project as below:
- Which API are you using : Google Analytics API option.
- Where Will you be calling the API From: Web browser( Javascript ) option.
- What Data will you be accessing: User Data option.
- Click on the What Credentials do I need button....
- Pop Appear Click on SET UP CONSENT SCREEN
- Switch to the OAuth consent screen tab: Specify the name of the Application in the Application name field.
- Select an email address in the Support email filed.
- In the Authorized domains field, specify the domains which will be allowed to authenticate using OAuth.
- Press the Save button
- Enable Google Analytics reports: enables the report functionality.
- Get Client ID and Client Secret
- In the left navigation panel, select the Credentials link under the APIs & Services section.
- In the Credentials tab, select the Client ID under from the OAuth 2.0 client IDs list.
- In the Client ID credentials page, the Client ID and Client secret will be displayed.