Contact Us 1-800-596-4880

Configuring User Analytics

Use Google Analytics to gain valuable insights into how consumers are using your APIs and portal, identify areas for improvement, make data-driven decisions to optimize the user experience, and drive business success.

Google Analytics tracks the following data:

  • API usage metrics:

    • API instance access requests

    • API specification downloads

    • Most viewed API

    • Total number of calls made to an API

  • User engagement metrics:

    • Active users

    • Login events

  • API Console usage:

    • API requests

      Measure the overall API usage and identity patterns in API consumption. Captures each time an API request is made through the API Console and the total number of API requests made.

    • API usage by endpoint

      Identities popular endpoints and monitors usage trends to optimize API design and resource allocation. Captures each time an API request is made to a specific endpoint through the API console and the number of requests made to each API endpoint.

Configure Google Analytics

To configure Google Analytics to send events from the portal:

  1. Set up a Google Analytics property using the instructions in the Set up the Analytics Google tag topic from the Google documentation.

  2. Navigate to the Builder.

  3. Click Settings > Security & Privacy.

  4. In the Content Security Policy (CSP) section, select Relaxed CSP: Permit Access to Inline Scripts and Allowed Hosts.

  5. From Settings, click Advanced.

  6. In the Advanced page, enter your Google Analytics Tracking ID.

  7. Select Let Google Analytics access your Salesforce data for deeper insights into search activity.

  8. Click Edit Head Markup.

  9. Add the following code and replace all instances of G-TRACK_ID with your Google Analytics Tracking ID:

    <script async src="https://www.googletagmanager.com/gtag/js?id=G-TRACK_ID"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'G-TRACK_ID');
      document.addEventListener('analyticsCustomEvent', function(e) {
          let detail = JSON.parse(JSON.stringify(e.detail));
          gtag('event', detail.eventName, detail.dimensions);
      });
    </script>
  10. From Setup, click Security & Privacy.

  11. Confirm that the following URLs show in the Trusted Sites for Scripts section:

  12. If the URLs are missing, add them by clicking Add Trusted Site.

  13. From Setup, click Security > Trusted URLs.

  14. Confirm that the same two URLs are in the list of the Trusted URLs section.

    API Experience Hub can now start sending Google Analytics from the portal.