Configure analytics tracking

You can configure Google analytics or your own custom analytics tracking, as described in the following sections.

Configure Google Analytics

Before you can configure Google Analytics, you’ll need a Google Analytics account and access to the tracking code that will be added to your portal pages and used to track activity on your site. For more information, see Google Analytics help.

To configure Google Analytics:

  1. Select Publish > Portals and select your portal.
  2. Select Settings in the drop-down menu in the top navigation bar.
    Alternatively, you can click Settings on the portal landing page.
  3. Click the Custom Scripts tab.
  4. Under Google Analytics, enter your Google Analytics tracking ID.
  5. Click Save.

Configure custom analytics tracking

Configure your own custom analytics tracking solution by passing event details to your own custom function. Your custom function must be defined as part of the portal.onAnalyticsEvent in the global namespace (declared on the window variable).

For example, you might want to send the event details to an analytics service other than Google Analytics:

<script>
window.portal = {};
window.portal.onAnalyticsEvent = (event) => {
  // log event to console
  console.log(event);
  // TODO: publish event to custom analytics service
}
</script>

Add your custom script to each page in your portal on the Custom Scripts tab of the Settings page. For more information, see Add custom scripts.

The portal generates the following types of events in the same format used by Google Analytics:

Event type Example format More information
Page visits
{
  hitType: 'pageview',
  page: '/apis'
};
Page tracking
Clicks on Execute on the Try it panel in the API reference doc
{
  hitType: 'event',
  eventCategory: 'docsEvents',
  eventAction: 'apixExecute'
}
Event Tracking