Setting up monitoring with custom javascript, enables you to control entirely the process but will require you to understand well Potions Events and the right occasions to send them.
This documentation will explain you how and when to send those events by
- showing examples of Potions Analytics Events sent to gtag (GA4)
- listing the Potions Analytics Events that need to be sent to your analytics
- detailing how to use GTM to send the events
Examples of Potions Analytics Events sent to gtag (GA4)
Potions uses 5 different events to create its monitoring.
- When an experience is shown to the user.
javascriptwindow.gtag("event", "potions", { experience_id : "df9ee7d4-795b-4a5f-b11b-1a2558672811", action_id: "show", item_ids : '["66","316","321","326","126"]' });
- When a product is clicked
javascriptwindow.gtag("event", "potions", { experience_id : "df9ee7d4-795b-4a5f-b11b-1a2558672811", action_id: "go_to_page", item_id : "66" });
- When a product is added to cart in a recommendation banner or an organized product list
javascriptwindow.gtag("event", "potions", { experience_id : "df9ee7d4-795b-4a5f-b11b-1a2558672811", action_id: "add_to_cart_item", item_id : "66" });
- when multiple products are added to cart
javascriptwindow.gtag("event", "potions", { experience_id : "df9ee7d4-795b-4a5f-b11b-1a2558672811", action_id: "add_to_cart_items", item_ids : '["66","316"]' });
- when an experiment audience is set
javascriptwindow.gtag("event", "potions", { experiment_id : "df9ee7d4-795b-4a5f-b11b-1a2558672811", audience_id : "A" action_id: "set_experiment_audience" });
Potions Analytics Events
A Potions Analytics Event is named
potions
and contains all the relevant informations as property values.Here is an example of a Potions Analytics Event sent to gtag (GA4) when showing an experience
A Potions Analytics Event can have the following properties :
Potions Analytics Event properties
Name
Description
Possible values
Potions Analytic Events Action Names
Potions Analytic Events Action Names 1
action_id
the action that led to sending the event
an action id
experience_id
the id of the experience concerned by the action
a Potions uuid
experiment_id
the id of the experiment (an AB Test campaign for instance)
a Potions uuid
item_id
the specific item concerned by the action (like the item added to cart in an “add_to_cart_item” action)
an item_id
item_ids
a list of items concerned by the action (like the items shown in a “show” action)
an array of item_id
You can also add optional and custom properties that will help you creating your own reports in your analytics tools, they will simply not be used by Potions.
For instance, it can be interesting to add the properties
experience_name
, experiment_name
, placement_name
to find more easily your indicators in your analytics. Potions Analytics Events are sent on the following occasions
Potions Analytic Events Actions
action_id
Description
Required properties
Optional properties
Click action
add_to_cart_item
when a product is added to cart in a recommendation banner or an organized product list
The table above explains the possible values of the action_id property.
Here are the possibles values for the other properties :
any uuid
: You can use any uuid for your placement_id, or your experiment id For placement_id : the uuid could be theid
attribute of the div in which you show a Potions experience. For experiment_id : the uuid is the unique identifier of your experiment. A visitor should stay in a given audience for a given experiment_id. Therefore your code needs to send once the set_audience event and keep the audience_id of the visitor for a given experiment_id. You can generate a uuid with the following tool (uuid version 4)
- a Potions uuid : You have to use the uuid you’ll find in Potions for this experience or experiment. You can see your experience_id in the top right corner of the Configure tab of your experience to send actions on this experience.
- A or B or C : Well… A, B or C
- an item_id : a string representing the id either of the sku or the variant of the item.
- an array of item_id : a stringified version of a javascript array of item_id
Using GTM to send Potions events
We strongly recommend using GTM to send your analytics events.
It will provide useful debugging methods and enable you to eventually switch analytics easily.
First you need to setup your GTM account to send Potions Analytics Events pushed in your datalayer to your analytics tool.
Setting up GTM to send Potions Events with custom JSThen, instead of calling gtag, you push the event to the datalayer, this way
javascriptwindow.datalayer.push( { event : `potions_event_${window.crypto.randomUUID()}`, potions: { experience_id : "df9ee7d4-795b-4a5f-b11b-1a2558672811", action_id: "add_to_cart_items", item_ids : '["66","316"]' } } );