You are here: Docs Technical Documentation Clearspring APIs In-Widget API Track

Track

Interaction Analytics

track provides various utilities for logging user behavior in a widget session.

Name Type Description
E_TOO_LONG property Error code for too-long input
track.event method Track a custom event
track.url.open method Open a URL using our link tracking service
track.url.create method Create a trackable URL

track.E_TOO_LONG

integer

Error code for too-long input.

back to table

track.event

method

Logs a custom event, recording its name and, optionally, arbitrary metadata.

Parameters
Name Type Required Purpose
name string (max 32 characters) yes Names your event in the event stream. This event name is what is used to aggregate event data across all sessions for this widget.
metadata string (max 96 characters) no Optionally associates metadata with this event. Useful if you require an event hierarchy; for example, if your widget plays videos, you might want to use a single "video_play" event name, passing the video's ID code as metadata.
Return
  • 0 on success
  • E_TOO_LONG if event name or metadata is too long
Example Usage

AS2

_level0.cs.track.event("new_user");
_level0.cs.track.event("video_play", selectedVideoId);

AS3

_api.track.event("new_user");
_api.track.event("video_play", selectedVideoId);

JavaScript

// Note: Only available in JS kernel
_api.track.event("new_user");
_api.track.event("video_play", selectedVideoId);
back to table

track.url.open

method

Open a URL redirected through our servers for tracking purposes. If you need to track clickthroughs back to your homepage, for example, opening URLs this way will associate them with the running session. Uses Flash's getURL to open the new window.

Parameters
Name Type Required Purpose
url url yes The URL to open (e.g., "http://example.org").
Example Usage

AS2

_level0.cs.track.url.open("http://example.org");

AS3

_api.track.url.open("http://example.org");

JavaScript

// Note: Only available in JS kernel

_api.track.url.open("http://example.org");
back to table

track.url.create

method

Like url.open, except the redirection URL is returned instead of directly opened.

Parameters
Name Type Required Purpose
url url yes The URL to wrap in our redirection service (e.g., "http://example.org").
Return
String: The URL redirected through our servers; e.g., "http://widgets.clearspring.com/r/476123fgvab1/http://example.org".
Example Usage

AS2

getURL(_level0.cs.track.url.create("http://example.org"));

AS3

navigateToURL(new URLRequest(_api.track.url.create("http://example.org"));

JavaScript

// Note: Only available for JS kernel

window.open(_api.track.url.create("http://example.org"),
null,
"height=200,width=400,status=yes,toolbar=no");