Introduction

Harvest has several helper functions and the most important function is the “trackEvent” method.

This function can be called by a developer to track certain user interactions. An example of how to call the Javascript API can be seen below.

harvest.trackEvent({
    "event":"pageview",
    "data": {
        "pageLanguage": "en"
    }
});

The Javascript object “harvest” is the library of Harvest Collect. It is available on the window.

To track something, you will need to call the method “trackEvent”.

This methods accepts a specific Javascript object or array of Javascript objects.

The Javascript object needs to contain at least the following properties:

  1. event
  2. data

event

This property tells us what type of event has occured (what type of user interaction did the user do). The following event types are available:

  1. pageview
  2. contentview
  3. click
  4. funnelstepview
  5. change
  6. dataview

For more information about the data model, read our data model documentation.

data

This property contains all meta data about the event that has occured. This is a Javascript object. The Javascript object can be empty.

Harvest Collect already retrieves a lot of information by default and also has several variables it recognizes by default.

For more information about the default meta data that is retrieved about a page, read the pageData meta data documentation.

It is possible to configure custom variables for each variable group.

For each specific type of event there are different required properties in the data object.

harvest object

The trackEvent method is part of the harvest object. For more information, read our harvest object documentation.

Page meta data

Usually, you can say that data about a page is relevant for all events that occur on the page. This is why we introduced so called page meta data. Everytime a pageview is tracked, we will save the data that was supplied in the data-attribute to page meta data. All subsequent events, except for the next pageview, will be enriched with that data.

For more information about the pageMetaData object.