Track Goal

Track Goal

The Track Goal API is used to record conversion events for a Full Stack A/B test experiment. A goal represents a meaningful action completed by a user, such as a signup, purchase, or feature usage.

Goal tracking helps PageSense measure experiment performance and determine which variation is driving better outcomes.

What this allows you to do  

By tracking goals, you can:

  • Measure conversions for Full Stack experiments

  • Compare performance across experiment variations

  • Identify which variation drives better results

  • Generate accurate experiment reports in PageSense

When to track a goal  

You should track a goal:

  • After the experiment has been activated for the user

  • When the user completes the action defined as a goal

  • At the exact point where the conversion occurs

Goal tracking should not be triggered before experiment activation.

Tracking a goal with user attributes  

User attributes can be passed while tracking a goal to ensure audience conditions are evaluated correctly and data is recorded accurately.

KOTLIN

  1. import com.zoho.pagesense.android.abtesting.PageSenseClient
  2. // Create a map to hold user attributes
  3. val userAttributes = mutableMapOf(
  4. "DeviceType" to "Phone",
  5. "OS" to "Android",
  6. "OSVersion" to "14",
  7. "DeviceModel" to "Pixel 8 Pro"
  8. )
  9. // Track the goal for the Full Stack A/B Test experiment
  10. pageSenseClient.trackGoal(
  11. experimentName,
  12. userId,
  13. goalName,
  14. userAttributes
  15. )

JAVA

  1. import com.zoho.pagesense.android.abtesting.PageSenseClient;
  2. import java.util.HashMap
  3. // Create a map to hold user attributes
  4. HashMap<String, String> userAttributes = new HashMap<>();
  5. userAttributes.put("DeviceType", "Phone");
  6. userAttributes.put("OS", "Android");
  7. userAttributes.put("OSVersion", "14");
  8. userAttributes.put("DeviceModel", "Pixel 8 Pro");
  9. // Track the goal for the Full Stack A/B Test experiment
  10. pageSenseClient.trackGoal(
  11. experimentName,
  12. userId,
  13. goalName,
  14. userAttributes
  15. ); 

Tracking a goal without user attributes  

If user attributes are not available, you can track a goal using only the experiment name, user ID, and goal name.

Only experiments targeting All Visitors will qualify in this case.

JAVA & KOTLIN

  1. // Track the goal without user attributes
  2. pageSenseClient.trackGoal(
  3. experimentName,
  4. userId,
  5. goalName
  6. );

Important notes  

  • Goals are tracked only if the user qualifies for the experiment

  • If the user is not part of the experiment, the goal call is ignored

  • Tracking the same goal multiple times may result in duplicate conversions

  • Always ensure the goal name matches the one configured in PageSense

  • This method does not return success or failure. It silently ignores calls if the user does not qualify for the experiment.

Best practices  

  • Track goals immediately after the conversion action

  • Use stable user identifiers

  • Avoid tracking goals on app launch or screen load

  • Keep goal names consistent and meaningful

What happens after tracking a goal  

Once a goal is tracked:

  • The conversion is recorded against the assigned variation

  • Data is sent to PageSense for reporting and analysis

  • Experiment reports update with conversion metrics