The Track Clicks on Element(s) goal is typically used to collect visitor data and clicks on buttons and elements present on your website. To know more about this goal, refer to the Track Clicks on Element(s). In VWO, you can define your testing goals in two ways:
- Adding goals from the Visual Editor UI.
- Add goals using the Goals page during the test creation.
Adding Goals From the Visual Editor UI
On the visual editor, select the element you want to track and choose the option Track Clicks.
If you are selecting a button, the editor opens a widget with a pref-filled goal name. You can modify the goal name per your requirements and click DONE. Post this, a new goal to track clicks on an element appears on the goals page.
Ensure to add every element for tracking if the CSS selector path is different. Select In an existing goal to track the variations in a single goal.
To learn more, refer to How to Add Goals Using Visual Editor.
Add Goals Using the Goals Page During the Test Creation
You can define the element you want to track on the Goals setup page.
- Login to your VWO account.
- Go to Testing > A/B, or you can select any other testing type per your requirements.
A/B Testing dashboard appears.
- In the dashboard, click CREATE.
- In the Enter URL of the page you want to test field, enter the URL of the webpage you want to test.
NOTE: To include or exclude URLs from the campaign, click the ADVANCED tab present next to the URL field. Using this tab, you can also define advanced pattern-matching options to either include a broad URL with wildcard entries or a specific URL. To learn about using different URL patterns, refer to Using URL Patterns in VWO.
- From the What hypothesis are you testing? dropdown, select a hypothesis you want to work with. This is an optional step.
NOTE: If you do not have a hypothesis yet or wish to create a new one, you can do so by clicking on the Create a New Hypothesis option present at the bottom of the hypothesis dropdown. To learn more about the hypothesis, refer to Hypothesis in VWO.
- In the Variations step, click Next.
- In the Goals step, click the edit icon present next to the New Goal and enter the name for your goal.
- From the Goals Type dropdown, select the option tracks clicks on element(s).
- Next, add a valid CSS selector path in the field that displays. To learn how to find the CSS path, click here.
NOTE: You cannot add XPath in place of a CSS selector.
- Make sure that the CSS selector path of the element to track is specified correctly. You can either specify the CSS selector path using the ID of the element, preceded by a hash(#)) or the associated class (preceded by a dot(.)).
NOTE: VWO will not track any conversions if the element has a dynamic CSS selector path. Ensure that you use static CSS classes to specify the path in goal settings.For example, in the screenshot below, #VWO-test-container-1 is the CSS path for the control version, and #VWO-test-container-2 is the CSS path for the Variation.
- For a Split URL test, make sure that control and variation have the same CSS selector path for any click on the element goals. However, if the CSS selector path is different for control and variations, add the selector paths for every element separated by a comma.
- For example, in the screenshot below, #VWO-test-container-1 is the CSS path for the control version, and #VWO-test-container-2 is the CSS path for the Variation version. To know more, refer to How to Create a Goal in VWO Testing?
How to Find the CSS Path of an Element?
- Right-click on the element you want to track and select Inspect Element. The developer tool displays the element properties.
- Right-click on the element property and select Copy and then click Copy Selector.
- Paste the CSS path in the Goals field.
Right-click on the element you want to track and select Inspect Element.
On the Developer tool, right-click on the element property and click Copy and CSS Selector.
Paste the CSS path in the Goals field.
If the element ID is dynamic, then you have to manually find the shortest CSS path. It is calculated from the nearest element ID by default. To know more about CSS selectors, click here.