HTML5 (Javascript) Client Reference
Class playerInsight
Language: Javascript (HTML5)
The PlayerInsight service. This class is used for setting segments for the current user and tracking events in PlayerInsight.
Example
Load PlayerInsight data:
Example
Set segments on the current user:
Example
Track a $1 purchase:
Properties | ||||
---|---|---|---|---|
|
||||
|
||||
Methods | ||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
playerInsight.playersOnline
|
The number of users online in this game. You must call refresh() to initialize this number.
playerInsight.segments
|
The list of PlayerInsight segments that are set on this user. You must call refresh() to initialize this list.
playerInsight.refresh
|
Refresh the players online counter and the current segments of the user.
Arguments
successCallback:function() | |
Callback function that will be called when the refresh is complete. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
playerInsight.sessionKeepAlive
|
Keep the PlayerInsight session alive. Call this method if you know the game hasn't made any other API requests in the last 20 minutes, and the player is still playing.
Arguments
successCallback:function() | |
Callback function that will be called when the operation is complete. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
playerInsight.setSegments
|
Assign custom PlayerInsight segments to the current user
Arguments
segments:Object | |
Custom segments for the user in PlayerInsight | |
successCallback:function() | |
Callback function that will be called when the operation is complete. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
playerInsight.trackEvent
|
Track the given event for the current user in PlayerInsight
Arguments
eventType:string | |
The name of the event to track. | |
value:Number | |
The amount to add to the counter value. | |
successCallback:function() | |
Callback function that will be called when the operation is complete. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
playerInsight.trackExternalPayment
|
Track a completed payment in PlayerInsight from an external non-PayVault payment method.
Arguments
currency:string | |
The currency the payment was made in. | |
amount:string | |
The amount of the payment in the given currency. | |
successCallback:function() | |
Callback function that will be called when the operation is complete. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
playerInsight.trackInvitedBy
|
Tell PlayerInsight who invited the current user in this session. Used for viral analysis.
Arguments
invitingUserId:string | |
The connectUserId of the user who invited this user. | |
invitationChannel:string | |
An identifier for the channel the invitation was received over, like 'email' or 'fb_invite'. | |
successCallback:function() | |
Callback function that will be called when the operation is complete. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |