Home > Developers
 
 
In-Widget API
Description
The SpinletsLab In-Widget API enables you to include custom tracking functionality within your Flash widgets. You can log specific events and track when a specific URL is opened from within the widget.
Object
The object that is provided in the In-Widget API is the track object. The track object provides utilities for tracking user behavior in a widget session.
Properties
E_TOO_LONG
Description

Error code for input that is too long.

Type

Integer

Read/Write

Read-only

Methods
event
Description

The event method logs a custom event, recording the event name and optional metadata.

Syntax

track.event(name, metadata)

Parameters
Name Type Required? Description
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 Values
  • 0 if successful
  • E_TOO_LONG property if name or metadata string is too long
Example Usage: ActionScript 2
  • _level0.sl.track.event("new_user");

  • _level0.sl.track.event("video_play", selectedVideoId);

Example Usage: ActionScript 3
  • _api.track.event("new_user");

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

url.open
Description

The url.open method opens a URL redirected through the SpinletsLab servers for tracking purposes. For example, if you need to track clickthroughs back to your home page, opening URLs this way will associate them with the running session. This method uses the Flash getURL function to open the new window.

Syntax

track.url.open(url)

Parameters
Name Type Required? Description
url URL Yes URL to open (for example, "http://example.org")
Return Values
None
Example Usage: ActionScript 2

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

Example Usage: ActionScript 3

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

Examples
The In-Widget API is made available to your widget in a variety of ways, depending on the language you are developing in.
Note: Because of a Flash player object serialization bug, you must allow access to your Flash application from the SpinletsLab domains:

System.security.allowDomain("www.spinletslab.com");

ActionScript 2

When loaded by the Spinlets™ widget container, the in-widget API services are loaded into an object stored on _level0 and accessible to the domain of your contained widget. (Note that content from other domains will not be granted access.) Function calls take the following form:

_level0.sl.category.method();

This general access method can be used to call any method in the function list from within your Flash application. For example, to call the track.event method from within the ActionScript 2 container, you would use code like this:

_level0.sl.track.event(eventCode);

ActionScript 3

Your application can access the in-widget API service classes at run time without having to do any fancy loading; they are defined as static objects on the root of the Spinlets™ widget container.

package test 
{
   public class WrapperTest extends Sprite
   {
      private var _api:Object;
      public function WrapperTest ()
      {
         Security.allowDomain("www.spinletslab.com");
         this.loaderInfo.addEventListener(flash.events.Event.COMPLETE,
         initHandler);
 
         // Grab a reference to the root of the SpinletsLab container
         _api = this.root.loaderInfo.loader.api; 
         _api.track.url.open("http://example.org"); 
      }
   }
}
About Us | FAQs | Feedback | Contact Us | Terms of Service | Privacy Policy
© 2009. Fuhu, Inc. All Rights Reserved.