By default, page view tracking is off per the Analytics Settings section on the Knowledge Tags implementation screen.
To add page view tracking:
- Click Pages in the navigation bar and click Knowledge Tags.
- Click on the Add Knowledge Tags to Website button.
- Click on the Select Entity button and select the desired entity.
- If applicable, select your desired locale.
- Enable the pixel. Under "Enable Pixels", select "Always On" or "Per-user Opt-In" from the dropdown.
- A modal with more information on pixels will appear. Read it and click Confirm.
- If applicable, select whether you would like to enable cookies.
- The script tag will update based on your selections. Add the script tag to your webpage using the instructions in the Add Knowledge Tags to Your Website help article.
Additionally, the number of times a user clicks or taps “Call” or “Get Directions” on a page will also automatically be tracked if you use the corresponding embed codes. See the Add Customer-Facing Content via Knowledge Tags help article.
Track Additional Events
To track more events, you can use our JavaScript library directly. To trigger an event through your own JavaScript, follow the model below: Yext.customEvent('EVENT_NAME', "entity_id")
If you want to call the standard events (e.g., “Get Directions” or “Phone Call”) via the JavaScript library, use the following event names:
GET_DIRECTIONS
Yext.customEvent("GET_DIRECTIONS", "entity_id")
TAP_TO_CALL
Yext.customEvent("TAP_TO_CALL", "entity_id")
For example, to track analytics for a button click for an entity with the Entity ID of 815, your script tag would look like this:
<script>
function buttonClickFunc(){
Yext.customEvent('button_clicked', "815")
}
</script>
<a onclick="buttonClickFunc()">Click me!</a>