PageViewTracker Lightning Component

Coveo for Salesforce 3 (May 2018)

The PageViewTracker Lightning component allows you to insert a page view tracker component in your Lightning community.

It takes care of wrapping and including the correct scripts and different resource references needed to do so.


Reference it in your Lightning component as you would for any other Aura component, using the namespace prefix of the Coveo package.

<aura:component implements="forceCommunity:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName"
  <CoveoV2:PageViewTracker />

The PageViewTracker Lightning component will use the clickableUri instead of the recordId when recordId is unavailable.

Resources Included With This Component

This component includes the Coveo JavaScript Search Framework, the jQuery (latest 3.x.x version) library, and the Coveo for Salesforce specific assets.

Since Lightning Locker is automatically enabled on this component, the underscore result templates aren’t supported. You must use HTML templates instead.

Aura Event

This component offers the following Aura event:


Fired when the search token has been fetched (see Generating a Custom Search Token for Lightning Components).


The component offers the following options:


The Coveo field name used to recommend results. Ensure this field exists with the index you’re using.

Default value is @sfid.


The value for the contentIdKey. This value should be a uniquely identifiable so Coveo Machine Learning can learn from the data.

Default value is the record id of the currently viewed page.

The component determines the value to enter for contentIdKey this way:

  1. If the value is added in this option or through custom code, it’s assigned as its contentIdValue.
  2. Otherwise, if in the URL of the page there’s a Salesforce Id, it’s assigned as its contentIdValue.
  3. Otherwise, the URL of the page is assigned as its contentIdValue.


The Salesforce type of the currently viewed page.

By default, this value is dynamically calculated, meaning that, when viewing an Account item, the contentType value would be Account.

Entering a value for this option overrides this logic, and always sends the same static contentType no matter which item type is being viewed.


Custom data to be sent with the view event.

It should take the form of a JSON with the following syntax:



Whether the component should use the non-minified versions of the different resources.

Default value is false.


Whether to manually send events, instead of letting the component do it automatically.

When enabling this option, you have to manually send the usage analytics events to the Coveo Platform.

Default value is false.


The name of the Advanced Lightning configuration to use for this component.

You usually want this value to be the same as your Coveo search component.

Default value is communityCoveo.

What's Next for Me?