In addition to the “standard” predefined events available upon enabling the “Event Tracking module”, “onClick” and “onSubmit” DOM events can also be defined to log such events in your contacts’ ActiveCampaign records, as well as a shortcode for page/post level logging.

onClick

To define/set an “onClick” logging event on any “clickable” DOM element, use HTML5 data-* attributes, as shown in the examples below:

Syntax:

To define/set an **onClick** logging event for any DOM HTML element that supports **onClick** use the HTML5 data attributes `data-mbr-eventname` and `data-mbr-eventvalue`.

Typical usage:

When the link is clicked create an ActiveCampaign event with the name **clicked-image** and log the event in the ActiveCampaign contact record with an event value of **logo.png**.

<img src="logo.png" data-mbr-eventvalue="logo.png" data-mbr-eventname="clicked-image">

When the link is clicked create an ActiveCampaign event with the name **clicked-link** and log the event in the ActiveCampaign contact record with an event value of **download info.pdf**.

<a href="https://yoursite.com/info.pdf" data-mbr-eventvalue="download info.pdf" data-mbr-eventname="clicked-link">

onSubmit

To define/set an “onSubmit” logging event for an HTML form, use HTML5 data-* attributes, as shown in the examples below:

Syntax:

To define/set an **onSubmit** logging event for a HTML form use the HTML5 data attributes `data-mbr-form-eventname` and `data-mbr-form-eventvalue`.

Typical usage:

When the form is submitted create an ActiveCampaign event with the name **submitted-form** and log the event in the ActiveCampaign contact record with an event value of **submitted update form**.

<form data-mbr-form-eventvalue="submitted update form" data-mbr-form-eventname="submitted-form">
  . *form elements* .
</form>

Note:

The “onSubmit” event is triggered and logged immediately upon submission of the form, whether it was submitted successfully or not, i.e. before any form validation takes place.

Shortcode

Finally, there is also a shortcode that can be used to trigger event logging at the page/post level. See: [mbr_log_event] shortcode for details.