Track Goal

Track Goal

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

  1. // Track the goal conversion for a Full Stack A/B Test experiment
  2. $pageSenseClient->trackGoal($experimentName, $userId, $goalName, $userAttributes);

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.


Prerequisites  

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.

Return Behavior  

  • 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.

This ensures conversions are tracked only for the users who are part of the A/B Test experiment.
 

Example Code

  1. use Zoho\PageSense\PageSenseClient;
  2. // Define user attributes
  3. $userAttributes = [
  4.     'Browser' => 'Chrome',
  5.     'Device' => 'Desktop',
  6.     'OS' => 'Windows 10'];
  7. // Track goal conversion for a Full Stack experiment
  8. $pageSenseClient->trackGoal($experimentName, $userId, $goalName, $userAttributes);

How the API Works  

When trackGoal() method is invoked, it follows a structured validation process before recording the goal conversion in PageSense:

1. Audience Targeting  

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.

2. User Qualification  

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.

Example:

Variation

Hash Range

Original

0 – 2000

Variation 1

2001 – 4000

Variation 2

4001 – 6000

If the user’s hash value falls within one of these ranges, the user qualifies and the goal event is tracked. If it falls outside, no event is sent.

3. Tracking and Analytics  

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.

4. Return Behavior  

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

 

Using trackGoal() Without User Attributes  

You can also call the API without providing user attributes.

Calling the Method

  1. // Track goal conversion without user attributes
  2. $pageSenseClient->trackGoal($experimentName, $userId, $goalName);

How It Works  

  • 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.

Best Practices  

  • 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.

For high-throughput apps, batch conversions where possible to reduce API overhead.

We hope this documentation helps make the process easy for you. Please feel free to reach out to us anytime by dropping an email to support@zohopagesense.com if you need more explanation or have any questions.

      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              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.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit

                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsFormstack alternativeEncrypted Forms

                              Wufoo alternativeSecure Forms

                              TypeformWCAG


                                          Create. Review. Publish.

                                          Write, edit, collaborate on, and publish documents to different content management platforms.

                                          Get Started Now




                                                            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.




                                                                Manage your brands on social media


                                                                  • Desk Community Learning Series


                                                                  • Digest


                                                                  • Functions


                                                                  • Meetups


                                                                  • Kbase


                                                                  • Resources


                                                                  • Glossary


                                                                  • Desk Marketplace


                                                                  • MVP Corner


                                                                  • Word of the Day


                                                                  • Ask the Experts


                                                                    Zoho Sheet Resources

                                                                     

                                                                        Zoho Forms Resources


                                                                          Secure your business
                                                                          communication with Zoho Mail


                                                                          Mail on the move with
                                                                          Zoho Mail mobile application

                                                                            Stay on top of your schedule
                                                                            at all times


                                                                            Carry your calendar with you
                                                                            Anytime, anywhere




                                                                                  Zoho Sign Resources

                                                                                    Sign, Paperless!

                                                                                    Sign and send business documents on the go!

                                                                                    Get Started Now




                                                                                            Zoho TeamInbox Resources





                                                                                                      Zoho DataPrep Demo

                                                                                                      Get a personalized demo or POC

                                                                                                      REGISTER NOW


                                                                                                        Design. Discuss. Deliver.

                                                                                                        Create visually engaging stories with Zoho Show.

                                                                                                        Get Started Now








                                                                                                                            • Related Articles

                                                                                                                            • Add a custom event goal to your variation

                                                                                                                              A custom event goal is a slightly more advanced method of tracking every single behavior of a visitor on the page you are testing. This includes watching a video, submitting a form, completing a payment, or any other event that could not be tracked ...
                                                                                                                            • Create and launch an A/B test in PageSense

                                                                                                                              A/B testing helps you analyze and observe how one version of a web page performs alongside another in front of your audience. On Zoho PageSense, you can quickly create, edit, and launch different versions of your web page, and test which one version ...
                                                                                                                            • Add a revenue goal to your variation

                                                                                                                              PageSense allows you to measure the revenue generated on your website when your visitor performs a successful purchase or payment transaction on your A/B (and Split URL) experiment page. To track the revenue value for each variation of your ...
                                                                                                                            • Add a page view goal to your variation

                                                                                                                              A page view goal in A/B testing lets you track conversions when a visitor lands on a specific page or set of pages. You can use advanced URL match types to track the goals on multiple pages. For example, if your goal is to check how many visitors ...
                                                                                                                            • Add a link click goal to your variation

                                                                                                                              A/B testing in Zoho PageSense enables you to create 'Link Click' goals that lets you to test which location in your web page gets thee maximum click on links and conversion rate. In this goal type, you can track how many visitors clicked on the ...
                                                                                                                              Wherever you are is as good as
                                                                                                                              your workplace

                                                                                                                                Resources

                                                                                                                                Videos

                                                                                                                                Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                                eBooks

                                                                                                                                Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                                Webinars

                                                                                                                                Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                                CRM Tips

                                                                                                                                Make the most of Zoho CRM with these useful tips.



                                                                                                                                  Zoho Show Resources