Introduction

An example of how you can track something with a data attribute can be seen below:

<body data-track-page='{}'>
..
</body>

The data attributes can help you track user interaction. We have the following user interaction specific attributes:

  1. data-track-page
  2. data-track-contentview
  3. data-track-click
  4. data-track-funnelstepview
  5. data-track-change
  6. data-track-dataview
  7. data-track-contentviewclick

Each of these attributes can be added to HTML elements. Each attribute has it’s own characteristics.

Besides these user interaction specific attributes, we also have some additional attributes, that change the default behaviour of the attributes.

  1. data-track-direct
  2. data-track-inner-links-only
  3. data-track-multiple
  4. data-track-viewdurations

data

Just as with the Javascript API, you need to provide a Javascript object that contains the meta data about the event. The Javascript object can be empty, as seen in the example. In the case of data attributes, the Javascript object will be in the form of JSON.

Besides the information you will add in the Javascript object, 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.

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.

Since the data attributes are tracked asynchronuously, we have made sure that before any data attribute is tracked, we first retreive the page meta data from the data-track-page. In the case where the data-track-page is not tracked first, the event still has the page meta data.

For more information about the pageMetaData object.