Event Tracking
The trackGoal() API records a conversion event for a specific goal within a FullStack A/B Test experiment.
This ensures conversions are attributed only to users who:
Meet audience targeting criteria, and
Fall within the experiment’s traffic allocation.
CopiedString variationName = pageSenseClient.trackGoal(experimentName, userId, goalName, userAttributes);Parameters for Event Tracking
Parameter | Type | Description |
experimentName | String | The name of the experiment activated. |
userId | String | A unique identifier for the user. |
goalName | String | The name of the goal being tracked. |
userAttributes | HashMap<String, String> | A map of user attributes used for audience targeting and segmentation. |
Process Flow
1. Audience Targeting : The API first checks if the user qualifies based on audience targeting rules defined in the experiment setup (conditions like browser, Device Os etc). If the targeting fails, then the API immediately stops and returns null
2. User Qualification via Traffic Allocation : The SDK checks if User Storage Service is enabled and if enabled and a stored version exists we can use the same. If no stored variation exists then Murmur hash is applied on userId to generate a deterministic number and is compared with the variation bucket defined by the traffic allocation. If the hash falls outside all ranges, then the user is not In the experiment and no goal is recorded.
3. Tracking & Analytics : If the user Passes audience targeting and Falls within a variation’s bucket range Then the goal conversion is recorded and sent to the PageSense server. The event data is then used for
Experiment reporting
Conversion metrics
Statistical analysis
Returns null ifAudience targeting failed
User is outside allocated traffic
Goal not recorded for this user
Example Workflow Diagram
Tracking without User Attributes
CopiedString variationName = pageSenseClient.trackGoal(experimentName, userName, goalName);
Similarly this api can also be called without userAttributes parameter. Here the user will qualify only for the experiments where the audience targeting criteria is configured as “All Visitors.”, If the experiment includes any additional audience targeting conditions—such as device type, location, or custom attributes—the user will automatically fail the qualification check due to the absence of use attribute data for evaluation.
Best Practices for Event Tracking
1. Always Track with Context : Include all relevant user attributes when calling trackGoal() (e.g., device type, region, plan type). This improves downstream segmentation and reporting accuracy.
ex: String variationName = pageSenseClient.trackGoal("PricingTest", "user123", "PurchaseCompleted", userAttributes);
2. Only Track for Qualified Users : Call trackGoal() only after confirming that the user is part of the experiment (audience targeting + traffic allocation). This avoids polluting your experiment data with unqualified users.
3. Track Once Per Conversion Type : Avoid calling the same goal multiple times for the same user unless you’re intentionally counting multiple conversions (e.g., “Add to Cart” per product). For one-time events (like “Signup”), ensure your app logic prevents duplicate calls.
4. Use Meaningful Goal Names : Goal names should be descriptive and unique to avoid confusion during analysis.
BAD : "ClickGoal1" , Good : "Checkout_CTA_Click"
5. Track at the Right Moment : Trigger goal tracking after the action is confirmed (e.g., after a successful payment API response, not just clicking “Pay”).Prevents false positives when an action is abandoned.
6. Ensure Reliable User IDs : Use consistent and persistent user IDs across sessions so conversion tracking can tie back to the correct variation.