Send an Event

The final line of code required in the Coveo Analytics JavaScript is the send command to the coveoua(), which passes the data captured to Coveo UA.

Send a Page View

Collecting page view data lets you measure the number of views you had for a specific page on your website. Every page must send at least one pageview event. No additional data is required, however you need to ensure that the data is sent after the Coveo Initialization to inherit the page data.

To send a pageview event, use the following command:

coveoua('send', 'pageview', <PAGE>, <FIELDS_OBJECT>);

Where:

<PAGE> (String, Optional) is set when the end user navigates to a new page in a single-page application (SPA).

<FIELDS_OBJECT> (Object, Optional) contains additional metadata to send along with the event (see Fields Reference). In this case, the send will only use the <FIELDS_OBJECT> for this single event, as you don’t want the attribute to be set for all the next events.

Examples
  • The following command sends an event that includes the current page’s information, such as its title, location, and referer:

      coveoua('send', 'pageview');
  • In a SPA, you must first use the set command to notify the script that the current page changed when the URL is dynamically updated:

      coveoua('set', 'page', '/mycurrentpage');
      coveoua('send', 'pageview');

Send a Generic Event

To send any type of generic event, use the event type, similar to the following command:

coveoua('send', 'event', <FIELDS_OBJECT>);

Where:

<FIELDS_OBJECT> (Object, Optional) contains additional metadata to send along with the event (see Fields Reference).

Page Fields Reference

Page fields are sent using the set command, or alongside a pageview event as shown in the following command:

coveoua('send', 'pageview', {
    page: '/mypage'
})

page (String)

The path portion of the page URL.

Example: /mycurrentpage

title (String)

The title of the page. The default value is retrieved from document.title.

Example: My Super Site

location (String)

The full URL of the page. The default value is retrieved from document.location.

Example: https://www.mysupersite.com/home

What's next for me?