Hotjar allows you to target users on a specific page variant using Events. Follow these steps to set up your Survey for targeting a specific test variant.
Events will take priority over URL-based targeting rules
If a targeted event is present on a page, it will cause the Survey to show regardless of any URL-specific rules on the page.
Add the Hotjar event code on your variant page(s).
Add the event code needed to trigger the Survey on the variant page(s) you wish to target. If you're unfamiliar with implementing events, check out our Events API documentation.
Below is an example to help you get started. Be sure to replace viewed_test_variant_b with the custom event name you will use for your Survey.
In the above example, the Survey would be displayed on the page variant which contains the event viewed_test_variant_b.
Visit the Survey page in Hotjar, click + New survey, then click Start from scratch.
Enter a Name and continue setting up the Survey until you reach the Targeting section.
In the Targeting section, select Specific pages.
Select Event from the Specific page dropdown and enter the event name.
Only alphanumeric characters, dashes, and underscores can be used in the event name. For example, viewed_test_variant_a.
Continue with the Survey set up, then select Active and click Create Survey.