Sitecore Personalize uses goals to track the performance of experiences and experiments. But what happens if your experience is live and you don’t see any executions or goals tracked in the performance tab for the experience? It can be hard to debug, test and troubleshoot goal tracking especially if the experience is hidden behind a login for example. But you can trigger the goal programmatically by making a series of api calls. I’ve created a Postman collection that you can download to make the process easy! Just update the environment with the appropriate values and you’ll be able to trigger your goals in no time!
Setup the experience
Create your experience using any variant, page targeting and filtering settings. Expand the goals section and ensure “track performance” is selected, then click Add goals. In this example, I’m using a custom goal. Give your goal a name and set your performance targets. Add the name of your custom event under “track event” and click the save button.
Make sure to preview your experience to ensure it displays properly. But keep in mind that an experience must be live in order for the system to track goals.
Trigger the goal
In order to trigger a goal in Sitecore Personalize the experience must be viewed in the same session as the goal event. I’ve setup a postman collection that simulates a user navigating the site, triggering the experience and executing the custom event.
In order to track your guest, you need a browser id (even for api calls). You can obtain a new browser id by using the “Get Browser Id” call in the postman collection or by using your existing browser id from your browser. To get your existing browser id, open your browsers dev tools and enter the following command in the console.
engage.getBrowserId()
You can update the environment vars in the postman collection to use your existing browser id.
Once you have your browser id, we will simulate the user journey through the site. I have included 5 page view calls in the postman collection along with 5 page variables. Set the urls of the pages you want to call, then execute the VIEW requests.
After you have made a few view requests, you’ll want to trigger the experience. You’ll need the friendly id of the experience which can be found on the experience page in the grey details box. Add this name in the environment variables for the postman collection the run the “Trigger Experience” request.
Once the experience is triggered, you can trigger your custom event. Add the custom event name and page url to the environment variables, then execute the “Custom Event” request.
In this example, we have triggered a goal for an experience using a custom event. You can just as easily trigger a page view goal by executing a VIEW request to the proper page after triggering your experience. Similarly, you may want to trigger the identity event if your experience requires the user to log into your site.
It is important to note that the goal will not appear on the report until the browsing session is closed! Your point of sale has a timeout period that will close a browsing session after X minutes of inactivity. When you are testing, you can execute the FORCE CLOSE request to end the session manually.
Check the data
Once you have triggered the goal and the session has ended, check the performance and operational data of the experience to validate the goal was triggered properly. You will see the successful execution of the experience in one graph
and the primary goal in a separate graph.
You can now be confident that your goal is configured correctly and Sitecore Personalize is tracking your goal correctly.