Class: Zuko

Zuko

Members

(static) COMPLETION_EVENT :Object

Standardised completion event to be used in sending a form completion event

Type:
  • Object

(static) FORM_VIEW_EVENT :Object

Standardised view event to be used when form is viewed.

Type:
  • Object

Methods

setAttribute(key, value) → {Zuko}

Sets a custom attribute for the current session

Parameters:
Name Type Description
key string

The name of the custom attribute

value string

The value for the custom attribute

Returns:

the Zuko tracking instance

Type
Zuko
Example
client
 .setAttribute('source', 'Google')
 .setAttribute('split_test', '1A')

trackEvent(event) → {Zuko}

Tracks a custom event for the current session

Parameters:
Name Type Description
event Event | Object | string

The event to be tracked

Properties
Name Type Description
type string

A short description of the custom event type

Returns:

the Zuko tracking instance

Type
Zuko
Examples
client.trackEvent(Zuko.FORM_VIEW_EVENT);
client.trackEvent({type: 'Address_Postcode: unable to locate address'});
client.trackEvent(Zuko.COMPLETION_EVENT);
client.trackEvent("Email validation failed");

unsetAttribute(key) → {Zuko}

Unsets a custom attribute for the current session

Parameters:
Name Type Description
key string

The attribute's category name to be unset

Returns:

the Zuko tracking instance

Type
Zuko
Example
client.unsetAttribute('source');

(static) deleteVisitorId()

Delete the current visitor's ID from the current Zuko object and remove the cookie

(static) getVisitorId() → {string}

Get the current visitor ID from the current Zuko object, or load from a cookie

Returns:

ID of the current visitor

Type
string

(static) setVisitorId(visitorId) → {string}

Set the visitor ID on the current Zuko object and store it in a cookie

Parameters:
Name Type Description
visitorId string

The ID of the current visitor

Returns:

ID of the current visitor

Type
string

(static) trackForm(params) → {Zuko}

Starts tracking a form on the page. Instantiates a tracking client. One tracking client should be used per form.

Parameters:
Name Type Description
params Object

A parameters object containing slug and target

Properties
Name Type Attributes Description
slug string

The "slug" identifier assigned to the form

target HTMLElement <optional>

The HTML element which contains your form, within which interactions will be tracked

Returns:

A new Zuko instance

Type
Zuko
Example
var client = Zuko.trackForm({
  target: document.getElementById('MyForm'),
  slug: 'my-form'
});

(static) trackMedium()

Tracks the current utm_medium parameter. Alternatively attempts to extract the medium for the current session from document.referrer, if there is no utm_medium parameter. The outcome is stored in a session cookie. If there is no utm_medium parameter and the referrer is from the same domain, the medium stored in the cookie is not updated as this traffic is from within the same site. This function is intended to be called on every page of a site, allowing the traffic medium to be tracked on all entrypoints into the site.