Activity tracking
This section explains how to create activities directly from the browser using the JavaScript SDK.
Creating activities
The JavaScript SDK allows you to track user activities directly from the client side. All activity types described in the Activities API can be created through the SDK if enabled in your security settings.
Behaviours configured with "JS Tracking" enabled can be tracked directly from the browser. When configuring these behaviours, it's important to set a reasonable "cool off" period to prevent potential abuse.
Creating activities via JavaScript is not recommended for production environments. This approach is vulnerable to manipulation by technically skilled users. For secure implementations, use the server-side SDKs and the ActivitiesService instead.
When creating activities through the JavaScript SDK:
- If successful, widgets automatically update to show new points or rewards, and notifications appear for unlocked rewards
- If unsuccessful, error messages are logged to the browser console
Here's how to create activities:
Activity data structure
The SDK supports creating various activity types. For a simple behaviour activity, you can just pass the verb:
For a detailed explanation of each activity type and its properties, see the Activities API documentation.
Bounty management
The SDK also provides methods to manage bounties:
Awarding bounties
Cancelling bounties
These operations trigger the respective events (mambo.activity.award_bounty and mambo.activity.cancel_bounty), which you can listen for to perform additional actions.