JavaScript events

WP Tao enables to handle events triggered on the client side (JavaScript).

Example of use

The example show a registered event for tracking the clicks of the button “Download WP Tao” on the home page of wptao.net.

frontside-tracking

Step 1 – Event registration

A new event will be registered identified as “click_download_wp tao.” Additionally, the colour and icon for this event and the title will be set.

Step 2 – Firing an event

The button has the following HTML code

The event must be fired from JavaScript. To do this, use wptaoEvent(action, value, tags, meta). The function assumes the following parameters:

  • action string required – an identifier of a previously registered event.
  • value string optional – an individual value of the event. It can be any number or text that will provide additional information about the event.
  • tags array optional – tags for this event in the form of an array, e.g. ["Tag 1","Tag 2","Tag 3"].
  • meta object optional – meta values for this event, e.g. {"meta_key":"meta_value"}.

Step 3 – Monitoring the events

Each click on the “Download WP Tao” will record information about the event. The results can be monitored on timelines.

frontside-tracking-2