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.

Usage

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"
                access="global">
  <CoveoV2:PageViewTracker />
</aura:component>

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) and Underscore.js (latest 1.x.x version) libraries, and the coveo.analytics.js client.

Aura Event

This component offers the following Aura event:

GetSearchToken

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

Options

The component offers the following options:

contentIdKey

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

Default value is @sfid.

contentIdValue

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.

contentType

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.

customData

Custom data to be sent with the view event.

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

{"key":"value"}

debug

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

Default value is false.

manual

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.

name

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.

Recommended Articles