How this API Works
When the trackGoal API is invoked, it follows a structured process to determine whether a variation should be allocated to the user. Below is a detailed breakdown of this process:
Audience Targeting
The API first evaluates whether the user qualifies for the experiment based on audience targeting conditions defined during experiment configuration.
These conditions are typically based on user attributes such as browser, device type, operating system, or any custom user data passed in the userAttributes.
- If the user’s attributes match the audience targeting conditions, the API proceeds to the next step.
- If the user does not meet these conditions, the API immediately returns null, indicating that the user is not eligible to be included in the experiment.
User Qualification
The next step is to determine if the user qualifies for the experiment based on the experiment’s traffic allocation settings.
- The API checks whether the User Storage Service is enabled. If it is enabled, the API will check for any stored variation for the user. If a variation has already been assigned and stored for the user in the User Storage Service, the API retrieves and returns that stored variation.
- If no stored variation exists, the API proceeds to allocate a new variation using variation bucketing.
- The API applies the MurmurHash algorithm to the user's ID (userId). This hashing algorithm consistently generates a unique numeric value between 0 and 9999 for each user ID, which serves as the user's hash value.
- Each variation within the experiment is assigned a specific range of hash values that corresponds to the variation’s allocated traffic percentage.
- The API checks if the user’s hash value falls within any of these defined ranges. If it does, the user will be considered qualified for the experiment. If the hash value falls outside all assigned ranges, it means the user is not qualified for the experiment and the goals will not be tracked.
Tracking and Analytics
If the user qualifies for the experiment and achieves the goal, the API sends the corresponding goal conversion details to the PageSense server. This data is used for analytics, reporting, and experiment performance evaluation.