Event tracking on FigPii
You can use the following functions to track multiple types of events based on your needs.
These events can be used as goals within your AB tests or as filters in your session recordings.
_fpEvent[]
If you're hardcoding the trigger for the event or firing it from a Tag Management solution, you can use _fpEvent.push() to send events to FigPii.
<script> window._fpEvent=window._fpEvent||[]; // Always required. window._fpEvent.push(["eventConversion",{value:"YOUR_EVENT_VALUE"}]); </script>
After setting up the trigger you can navigate to Site Goals on your FigPii dashboard and define the goal.
Revenue tracking with _fpEvent
To track revenue on your website, fire this event after a successful order has been placed.
<script> window._fpEvent=window._fpEvent||[]; window._fpEvent.push(["addRevenue",{revenue:"ADD_REVENUE_AMOUNT_HERE"}]); window._fpEvent.push(["eventConversion",{value:"purchase"}]); </script>
After setting up the trigger for the purchase event, you can navigate to Site Goals on your FigPii dashboard and define the goal.
Using purchase as the event value will automatically associate revenue with the goal.
track()
<script> FIGPII.helpers.track(eventType: string, selector: string, eventValue: string) </script>
Using this function, you can attach trackers to elements on the page without the hassle of having to worry about querySelectorAll, adding forEach, etc.
How to use the function:
To attach the events supply the eventType — all types supported by addEventListener() are supported — for example "click"
<script> FIGPII.helpers.track("click", selector: string, eventValue: string) </script>
Then add the CSS selector for the target element
<script> FIGPII.helpers.track("click", ".foo", eventValue: string) </script>
And finally provide the desired value which later on will be used within your AB test
<script> FIGPII.helpers.track("click", ".foo", "bar") </script>
Calling this function will attach a click event to any element that has .foo as a class and will fire "bar" to FigPii tracking.
An example of tracking add to cart button on Shopify:
<script> FIGPII.helpers.track("click", "form[action='/cart/add'] button[type=submit]", "add_to_cart") </script>