To ingest data from Google Analytics to Data 360, set up an external credential.
Before You Begin
Before you begin, complete these steps:
- In Google Cloud Console, enable the Google Analytics Data API and the Google Analytics Admin API.
- Configure an External OAuth consent screen. Add the users who authenticate the connection as test users, or publish the app before using the connection in production.
- Create an OAuth 2.0 client ID with Web application as the application type.
- In Salesforce Setup, create an OAuth provider with OpenID Connect as the provider type. Enter the Google client ID and client secret, and add the Salesforce callback URL to the Google OAuth client's Authorized redirect URIs. The callback URL must match exactly, including whether it has a trailing slash.
- For the OAuth provider default scope, enter
https://www.googleapis.com/auth/analytics.readonly. You don't need to add theopenidscope.
note: Google refresh tokens issued while the OAuth consent screen is in testing expire after 7 days. Publish the app to production to prevent the connection from requiring weekly reauthentication.
Set Up External Credentials
-
From Setup, in the Quick Find box, enter
Named Credentials. Then select Named Credentials (1).
-
On the External Credentials tab (2), click New.
-
Enter a label and name for your external credential. The name can’t contain spaces. You can use underscores.
-
For Authentication Protocol, select OAuth 2.0.
-
For Authentication Flow Type, select Browser Flow.
-
For Authentication Provider, select the provider you created.
-
Click Save.
-
-
Add a principal to the external credential.
-
In the external credentials that you created, under Principals, click New.
-
Enter the parameter name. You can include spaces.
-
For Identity Type, select Named Principal.
-
For Scope, enter
https://www.googleapis.com/auth/analytics.readonly refresh_token.The
refresh_tokenscope requests offline access so Google returns a refresh token. Without a refresh token, the connection can stop working after the access token expires. -
Set the Sequence Number to
1. -
Click Save.
-
-
Authenticate your external credentials.
-
Under Principals, from the Actions dropdown menu, select Authenticate.
-
Follow the authentication flow and confirm access permissions.
-
To connect Data Cloud to Google Analytics click Allow.
After you authenticate, the status changes to Configured.
-
-
Define the named credential.
-
In the Named Credentials Tab, click New. Then enter a label and name. The name can't contain spaces, but you can use underscores.
-
For the URL, enter
https://analytics.googleapis.com. -
For external credentials, select the credential that you created.
-
Click Save.
-
-
Enable external credential access with a permission set.
-
From Setup, in the Quick Find box, enter
Permission Sets. Then select it. -
Create a permission set or select an existing permission set for users who authenticate the external credential.
-
Under External Credential Principal Access, add the external credential principal that you created.
-
Assign the permission set to the user who authenticates the external credential.
-
Click Save.
-
Troubleshoot Authentication Errors
If authentication displays Problem Logging In, review the ErrorDescription value in the browser URL. The error page doesn't show the detailed Google error.
| Error | Resolution |
|---|---|
Remote_Error or invalid_request |
Verify the OAuth consent screen configuration and the Google client ID and secret. |
redirect_uri_mismatch |
Add the exact Salesforce callback URL to the Google OAuth client's Authorized redirect URIs. |
invalid_client |
Verify that the client ID and client secret in the Salesforce OAuth provider match the Google OAuth client. |
access_denied |
Verify that the authenticating Google account is a test user while the OAuth consent screen is in testing, or publish the app to production. |