Events are used for measuring the success of campaigns, and for segmenting users who performed these interactions. They are implemented by adding code to your site that fires lets Dynamic Yield know every time a particular action occurs. For common interactions (e.g. purchase, login, add to cart) you should use the schema documented here. However, if you want to fire an event for an interaction that is unique to your business or does not appear in that list, you can fire a custom event using the syntax in this article.
Custom Event Syntax
JavaScript
DY.API("event", {
name: "EVENT_NAME",
properties: {
[FIRST PROPERTY NAME]: "[PROPERTY VALUE]",
[SECOND PROPERTY NAME]: "[PROPERTY VALUE]",
value: "[MONETARY VALUE]"
}
})
name: Event name. This name will appear in the Dynamic Yield console, when creating an audience and in the reports.
properties (optional): Any additional information about the event. This allows you to create a more refined audience, not with all users who fired this event, but only users who fired the event with a specific property. For example, if the event is rating a product, you can add the rating score as a property, and create an audience of users who rated a product with a score of 5. There is no limit to the number of properties you can include in an event.
value (optional): Adding a property with the name "value" is different from adding other custom properties. Dynamic Yield uses this property name to describe the monetary value of an event. This allows you to later create a Goal based on the event, set its value to be the same as the event value, and set the primary metric of the experience to be the revenue of this goal.
Examples:
DY.API("event", {
name: "zoom"
})
DY.API("event", {
name: "Satisfaction Survey",
properties: {
Customer Support: "Satisfied",
Shipping: "Very satisfied"
}
})
DY.API("event", {
name: "Donation",
properties: {
type: "charity",
value: 200.00
}
});
Tip: Usually, firing an event means adding code to your site. However, you can use a template called "Fire Event" in Custom Code campaigns to fire an event without making any code changes. Read more about it in our Community.
Off-Site Events
You can also fire events from off-site or websites without the Dynamic Yield script (for example, 3rd party websites) using a pixel with the following syntax:
<img height='1' width='1' border='0' src='//px.dynamicyield.com/dpx?sec=[SITE ID]&name=[EVENT NAME]&props={"[FIRST PROPERTY NAME]": "PROPERTY_VALUE", value: "[MONETARY VALUE]"}' />
For example:
<img height='1' width='1' border='0' src='//px.dynamicyield.com/dpx?sec=8765000&name=Product_Return&props={"Number of Products": "2"}'/>
px.dynamicyield.com: If you're using Dynamic Yield with EU data center (i.e. if the URL of the Dynamic Yield console is adm.dynamicyield.eu), change the domain to px.dynamicyield.eu.
sec: Site ID. The site ID appears in the URL when you're in the Dynamic Yield console, next to the "SectionId" (It's a 7 digit number that starts with 87 or 98).
name: Event name. This name will appear in the Dynamic Yield console, in the audience condition, and the reports.
props: The properties and their values you want to send in the event.
Note: If you want to attribute off-site events to your campaigns in experience reports, the attribution window of the campaigns must be set to 1 day or 7 days, but cannot be session-based.