Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.optimizely = window.optimizely || [];
- var clickedBanner = 0;
- // Query Optimizely user events and filter to clicks
- var userBehaviorQueryData = optimizely.get("behavior").query({
- version: "0.2",
- sort: [{
- field: ["time"],
- direction: "descending"
- }],
- filter: [{
- field: ["type"],
- value: "click"
- }]
- });
- // Loop through the events and increment by one each time the click event is found
- userBehaviorQueryData.forEach(function(event) {
- if (event.name === '1633341726_click_hero_banner') {
- clickedBanner += 1;
- }
- });
- // Push the click value to a user attr which can be used in results segmentation
- window["optimizely"].push({
- "type": "user",
- "attributes": {
- "Clicked Hero Banner": clickedBanner
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement