Great! Let’s move on to step 2, which involves creating API credentials for your Google Cloud project to access the Google Analytics data programmatically. Here are the detailed instructions:
Step 2: Create API Credentials
- Access the Google Cloud Console: Go to the Google Cloud Console (https://console.cloud.google.com) and sign in using your Google account.
- Select your project: From the project dropdown menu at the top of the page, choose the project you created in step 1.
- Navigate to API Credentials: On the left sidebar, click on “APIs & Services” -> “Credentials”.
- Click on “Create Credentials”: In the Credentials section, click on the “Create Credentials” button and select “OAuth client ID”.
- Choose application type:
- Select “Web application” as the application type.
- Configure the OAuth client ID:
- Enter a name for your credentials (e.g., “Google Analytics API Access”).
http://localhostas the origin and
http://localhost/redirectas the redirect URI.
- Click the “Create” button to generate the OAuth 2.0 Client ID.
- Retrieve the Client ID and Client Secret:
- After creating the OAuth client ID, you will see a popup or a page displaying the Client ID and Client Secret values.
- Take note of the Client ID and Client Secret as you will need them in the next steps for authentication.
With the API credentials created, you have the necessary authorization to access the Google Analytics data through the Google Analytics Reporting API. In the next steps, we will set up the development environment and authenticate using these credentials to retrieve the historical data.