---
title: PageViewTracker Lightning component
slug: '1017'
canonical_url: https://docs.coveo.com/en/1017/
collection: coveo-for-salesforce
source_format: adoc
---
# PageViewTracker Lightning component
The _PageViewTracker_ Lightning component allows you to insert a page view tracker component in your Experience Cloud site.
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.
```xml
```
> **Note**
>
> 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](https://github.com/coveo/search-ui), the [jQuery](https://jquery.com/)(latest 3.x.x version) library, and the Coveo for Salesforce specific assets.
> **Note**
>
> Since Lightning Locker is automatically enabled on this component, the [underscore result templates](https://docs.coveo.com/en/413#using-the-underscore-engine) aren't supported.
> You must use [HTML templates](https://docs.coveo.com/en/413#using-the-html-engine-recommended) instead.
## Aura method
### `sendPageView`
When the [`manual`](#manual) option is set to `true`, use this function to manually send view events.
Required parameters:
* `contentIdKey`: A Coveo field name used to recommend results.
* `contentIdValue`: The value of the selected `contentIdKey` field.
**Example**
[,xml]
```
```
```javascript
// myPageViewTrackerWrapperController.js
{
doInit : function(component, event, helper) {
var myTracker = component.find('myPageViewTracker');
myTracker.sendPageView({
contentIdKey :'@clickableuri',
contentIdValue: 'https://mycommunity.salesforce-communities.com/mycommunity/s/?app=commeditor&view=editor&viewid=3bc9966a-db89-4aaf-9907-948a57084281&formFactor=LARGE&livePreviewBrandingSetID=f29190fc-cd8b-43c7-b2a6-bdfbba1fd3ef',
contentType: 'communityPageView',
customData: {age: 29}
});
}
}
```
You can safely call the `sendPageView` method even when the `PageViewTracker` component hasn't yet initialized;
the events are added to a queue and are sent once everything is ready.
## 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 Coveo Lightning Aura components](https://docs.coveo.com/en/2745/)).
## 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.
> **Note**
>
> The component determines the value to enter for `contentIdKey` this way:
>
> . If the value is added in this option or through custom code, it's assigned as its `contentIdValue`.
> . Otherwise, if in the URL of the page there's a Salesforce Id, it's assigned as its `contentIdValue`.
> . 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:
```json
{"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 [Coveo Analytics events](https://docs.coveo.com/en/260/) to Coveo, using the [`sendPageView`](#sendpageview) function.
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`.