standard_ event_ data
variable | standard_event_data: event_type, context: string
returns string
Generates a JSON payload for standard events.
The filter generates JSON payloads for standard events.
It can be used on product,
collection, and
cart objects.
The only supported event type is "view".
For products, you can optionally pass a context parameter. Valid values are:
page, search, collection, dialog, and recommendation. If omitted, context is null.
For carts, you can optionally pass a context parameter. Valid values are:
page and dialog. If omitted, context is null.
If the cart hasn't been created yet, then the payload returns null for the cart field.
The context parameter is ignored for collections.
{{ product | standard_event_data: "view", context: "page" }}
Code
{{ product | standard_event_data: "view", context: "page" }}Output
{"product":{"id":6786188247105,"title":"Health potion","handle":"health-potion","selectedVariant":null},"context":"page","selectedOptions":[]}
Output
{"product":{"id":6786188247105,"title":"Health potion","handle":"health-potion","selectedVariant":null},"context":"page","selectedOptions":[]}Anchor to Collection view event data
Collection view event data
{{ collection | standard_event_data: "view" }}
Code
{{ collection | standard_event_data: "view" }}Output
{"collection":{"id":null,"handle":"all","productsCount":19}}
Output
{"collection":{"id":null,"handle":"all","productsCount":19}}Anchor to Cart view event data
Cart view event data
{{ cart | standard_event_data: "view", context: "dialog" }}
Code
{{ cart | standard_event_data: "view", context: "dialog" }}Output
{"context":"dialog","cart":null}
Output
{"context":"dialog","cart":null}Was this page helpful?