The trackGoal() method is used to record goal conversions for Full Stack A/B Testing experiments in PageSense. It records the conversion events in PageSense only for the users who qualify for the experiment.
This API can be invoked with or without user attributes, depending on how your experiment’s audience targeting rules are configured.
Calling the Method
Method Parameters
Parameter | Type | Description |
experimentName | string | The name of the experiment where the goal is defined. |
userId | string | A unique identifier for the user. |
goalName | string | The name of the goal being tracked. |
userAttributes | array | (Optional) Associative array of user attributes used for audience targeting and segmentation. |
While invoking this method, ensure that:
The experiment is activated in the web page where the goal is being tracked.
The method is invoked only when the conversion conditions associated with the goal are satisfied.
If the user qualifies for the experiment, the goal conversion is recorded and sent to PageSense server.
If the user does not qualify, or falls outside the experiment’s traffic allocation, the API silently ignores the conversion request.
Example Code
When trackGoal() method is invoked, it follows a structured validation process before recording the goal conversion in PageSense:
The API checks whether the user qualifies for the experiment based on audience targeting conditions defined in PageSense.
These conditions typically include user attributes such as browser, device type, OS, or any custom fields passed in the user attributes.
If the user attributes match the audience targeting condition, evaluation continues.
If the user attributes do not match the audience targeting condition, the goal conversion details will not be sent to PageSense.
The API next verifies whether the user falls within the experiment’s traffic allocation range.
If the User Storage Service is enabled, the SDK retrieves any previously assigned variation for the user (ensuring consistent tracking across sessions).
If no variation is stored, a new one is allocated using deterministic bucketing (based on hashing).
The SDK then applies the MurmurHash algorithm to the user’s ID (userId) to produce a numeric hash between 0–9999.
Each variation in the experiment is assigned a unique hash range corresponding to its traffic percentage.
Variation | Hash Range |
Original | 0 – 2000 |
Variation 1 | 2001 – 4000 |
Variation 2 | 4001 – 6000 |
Once qualification succeeds and the goal condition is triggered:
The SDK packages the experiment name, user ID, goal name, and variation ID.
It sends this conversion event to the PageSense backend using a secure HTTPS request.
This data powers conversion metrics, probability of win, and confidence reports in the experiment dashboard.
Condition | SDK Behavior |
User qualifies and goal achieved | Sends goal event to PageSense |
User doesn’t qualify | Ignores call silently |
Network error / invalid SDK key | Logs error (if logging enabled), does not retry automatically |
You can also call the API without providing user attributes.
Calling the Method
Only Experiment Name, User Id, and Goal Name are required.
Audience targeting still runs, but users get qualified for the experiment only if the audience targeting condition “All Visitors”. For experiments with specific audience targeting rules (e.g., device = mobile), users will not qualify for the experiments as there are no user attributes passed.
If user is qualified for the experiment, the API uses the MurmurHash algorithm to determine the variation and record the goal against the variation allocated.
If the user is not qualified for the experiment, no conversion event will be triggered.
Always call trackGoal() API immediately after a conversion event.
Use consistent User Id values across all SDK methods for deterministic behavior.
If your backend processes conversions asynchronously via jobs or queues, ensure the SDK call is included in the post-processing stage.
Handle silent no-ops gracefully — not all users will qualify for tracking.
Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.
If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.
You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.