Examples of Goal Tracking

1. Revenue Tracking :
Track revenue-related goals (e.g., purchases, subscription upgrades) by sending the revenue value along with the goal name.
When to Use:

  • Purchase confirmations

  • Subscription renewals

  • One-time payments

Copiedimport java.util.HashMap; 
// Create the User Attributes object 
HashMap<String, String> userAttributes = new HashMap<>(); 
// Add the User Attribute values 
userAttributes.put("Browser", "Chrome"); 
userAttributes.put("planType", "Premium");
userAttributes.put("country", "US");

// Activate the FullStack A/B Test Experiment 
String variationName = pageSenseclient.trackGoal("PricingTest", "user123", "PurchaseCompleted", 99.99, userAttributes);
Copied// Create the User Attributes object
Dictionary<string, string> userAttributes = new Dictionary<string, string>();
 // Add the User Attribute values
userAttributes["Browser"] = "Chrome";
userAttributes["Device"] = "Desktop";
userAttributes["OS"] = "Windows 10";
 // Track the Goal for the FullStack A/B Test Experiment 
pageSenseclient.trackGoal("PricingTest", "user123", "PurchaseCompleted", 99.99, userAttributes);

2. CTA Click Tracking :
Track important call-to-action (CTA) clicks such as Sign Up, Add to Cart, or Start Free Trial.
When to Use:

  • Sign-up button clicks

  • “Add to Cart” actions

  • Download button clicks
     

Copiedimport java.util.HashMap; 
// Create the User Attributes object 
HashMap<String, String> userAttributes = new HashMap<>(); 
// Add the User Attribute values 
userAttributes.put("Browser", "Chrome"); 
userAttributes.put("planType", "Premium");
userAttributes.put("country", "US");

// Activate the FullStack A/B Test Experiment 
String variationName = pageSenseclient.trackGoal("OnboardingTest", "user456", "StartTrialCTA_Clicked", userAttributes);
Copied// Create the User Attributes object
Dictionary<string, string> userAttributes = new Dictionary<string, string>();
 // Add the User Attribute values
userAttributes["Browser"] = "Chrome";
userAttributes["Device"] = "Desktop";
userAttributes["OS"] = "Windows 10";
 // Track the Goal for the FullStack A/B Test Experiment 
pageSenseclient.trackGoal("OnboardingTest", "user456", "StartTrialCTA_Clicked", userAttributes);

3. Multi-Goal Tracking in One Flow : 
Track multiple goals for the same user in a single session to measure different conversion points.

CopiedString variationName = pageSenseclient.trackGoal("ProductPageTest", "user789", "ProductLink_Clicked", userAttributes);

// Other code

String variationName = pageSenseclient.trackGoal("ProductPageTest", "user789", "AddToCart", userAttributes);
CopiedpageSenseclient.trackGoal("ProductPageTest", "user789", "ProductLink_Clicked", userAttributes);

// Other code

pageSenseclient.trackGoal("ProductPageTest", "user789", "AddToCart", userAttributes);