Custom JavaScript campaigns let you create custom JavaScript code to add or manipulate any element on your page or app. You can change, move, swap, or otherwise manipulate any element with almost no limitations. This lets you fully utilize Dynamic Yield’s optimization and personalization capabilities to leverage any modification you want to try out.
Creating a Custom Code Campaign
- Go to Site Personalization › New Campaign and click Custom Code.
- Specify the campaign settings such as trigger, frequency, and advanced settings. For details, see below.
- Configure the targeting settings of the experience to determine when, where, and for whom the experience is displayed.
- Create variations using templates, based on other experiences, or by using a data feed. When you are done with each variation, click Save Variation.
- Set the allocation, primary metric, and advanced experience settings.
- Configure how much of your traffic to allocate to each variation, and if you want to allocate any traffic to the control group.
- Click Save Experience.
- Click the "+" icon to create an additional targeted experience.
- Click Preview to see how your campaign will appear, and click Save and Publish when you are ready to go.
Custom Code Campaign Settings
Trigger
- Page Load – execute the code immediately upon pageload of the relevant pages (the specific pages are defined in the Targeting step upon adding variations)
- Time on Page – execute the code only after a certain amount of time has passed since pageload
- Exit Intent – execute the code only once the visitor has exhibited exit intent by moving his or her mouse cursor outside the webpage area (desktop only)
- Event – execute the code only once a specific Event has been fired on the page
- Advanced – allows you to set any multiple selection or combination of triggers out of the triggers specified above, as well as:
- Element click – execute the code only once the visitor has clicked with his or her mouse over a specific element on the page, defined with a CSS Selector
- Element mouseover – execute the code only once the visitor has hovered with his or her mouse cursor over a specific element on the page, defined with a CSS Selector
- Element load – execute the code once a specific element has loaded on the page, defined with a CSS Selector
- External component – execute the code only once an external component, such as a jQuery, has loaded
Frequency
- Once per pageview – Your visitors will be exposed to the code each and every time they meet the targeting conditions, with every new pageload
- Once per session – Your visitors will be served the code once they meet the targeting conditions, and will no longer be exposed to it during the remaining pageviews of their session
- Once per day/ week month – Your visitors will be served the code once they meet the targeting conditions, and will not be exposed to it on any pageview during the remainder of the day, week, or month, depending on the timeframe selection
- Once per user – Your visitors will be served the code once they meet the targeting conditions, and will not be exposed to it ever again