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.

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).

What's Next for Me?