{
  "rules": [
    {
      "name": "TrackPageLoad",
      "payload": {
        "event": "trackPageLoad",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-0001",
          "ucsState": "non-pv",
          "eventName": "pageLoad",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "PL-$[eventSource]"
        },
        "page": {
          "pageName": "$[eventSource]:$[pageName:home]",
          "language": "$[language]",
          "loadTime": "$[loadTime]",
          "breakPoints": "$[breakpoint]",
          "loB": "$[loB]",
          "phoneDisplayed": "$[phoneDisplayed:none]"
        },
        "faq": {
          "faqDisplay": "$[faqDisplay:false]"
        },
        "chat": {
          "chatDisplay": "$[chatDisplay:false]"
        },
        "banner": {
          "bannerDisplay": "$[bannerDisplay:false]"
        },
        "user": {
          "bncId": "$[bncId:undefined]",
          "loggedStatus": "$[loggedStatus:false]"
        }
      }
    },
    {
      "name": "TrackAdvisorCode",
      "selector": "button.client-login-section-login",
      "delegate": ".advisor-login-form",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]",
          "ucsState": "non-pv",
          "eventName": "formLaunch",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CCTA-$[eventSource]",
          "interaction": "$[ctaText]"
        },
        "page": {
          "pageName": "$[eventSource]:$[pageName:home]",
          "language": "$[language]",
          "loadTime": "$[loadTime]",
          "breakPoints": "$[breakpoint]",
          "loB": "$[loB]",
          "phoneDisplayed": "$[phoneDisplayed:none]"
        },
        "search": {
          "advisorCode": "$[advisorCode]",
          "repCode": "$[repCode]"
        }
      },
      "variables": {
        "advisorCode": {
          "type": "selector",
          "selector": "this",
          "parent": "form[name='loginForm'].login-form",
          "child": "input[name='username'].form-control",
          "method": "val"
        },
        "repCode": {
          "type": "selector",
          "selector": "this",
          "parent": "form[name='loginForm'].login-form",
          "child": "input[name='password'].form-control",
          "method": "val"
        }
      }
    },
    {
      "name": "TrackPageReady",
      "selector": "window",
      "events": "load",
      "payload": {
        "event": "trackPageView",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-0002",
          "ucsState": "pv",
          "eventName": "pageReady",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "PR-$[eventSource]"
        },
        "page": {
          "pageName": "$[eventSource]:$[pageName:home]",
          "language": "$[language]",
          "loadTime": "$[loadTime]",
          "breakPoints": "$[breakpoint]",
          "loB": "$[loB]",
          "phoneDisplayed": "$[phoneDisplayed:none]"
        },
        "faq": {
          "faqDisplay": "$[faqDisplay:false]"
        },
        "chat": {
          "chatDisplay": "$[chatDisplay:false]"
        },
        "banner": {
          "bannerDisplay": "$[bannerDisplay:false]"
        },
        "user": {
          "bncId": "$[bncId:undefined]",
          "loggedStatus": "$[loggedStatus:false]"
        }
      }
    },
    {
      "name": "TrackSiteSearch",
      "selector": ".searchResult.section",
      "events": "search",
      "delay": 1000,
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-SCS",
          "ucsState": "non-pv",
          "eventName": "searchSite",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "SCS-$[eventSource]"
        },
        "search": {
          "searchTerms": "$[searchTerms]",
          "searchResults": "$[searchResults:0]"
        }
      },
      "variables": {
        "searchTerms": {
          "type": "selector",
          "selector": "this",
          "parent": ".searchResult.section",
          "child": "#search-result-topbar-query-text input[name='q']",
          "method": "val"
        },
        "searchResults": {
          "type": "selector",
          "selector": "this",
          "parent": ".searchResult.section",
          "child": "#search-result-header-number",
          "method": "text",
          "args": {
            "match": "\\d+"
          }
        }
      }
    },
    {
      "name": "TrackOtherCTA_SearchResultClick",
      "selector": "ul#search-result-detail-pages-container li .search-result-detail",
      "delegate": ".searchResult.section",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-CCTA",
          "ucsState": "non-pv",
          "eventName": "clickCTA",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CCTA-$[eventSource]",
          "interaction": "scs_answer - $[resultHref]"
        }
      },
      "variables": {
        "resultHref": {
          "type": "selector",
          "selector": "this",
          "method": "attr",
          "args": {
            "attr": "onclick",
            "match": "(http(s)?:\\/\\/)([\\w-_\\.\\/]+)(\\.html)"
          }
        }
      }
    },
    {
      "name": "TrackClickToCall",
      "selector": "a[href^='tel:']",
      "delegate": "body",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-CC",
          "ucsState": "non-pv",
          "eventName": "clickToCall",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CC-$[eventSource]",
          "interaction": "$[ctaTel]"
        }
      },
      "variables": {
        "ctaTel": {
          "type": "selector",
          "selector": "this",
          "method": "attr",
          "args": {
            "attr": "href",
            "match": "\\+?[\\d- \\(\\)]+"
          }
        }
      }
    },
    {
      "name": "TrackOtherCTA_PDF_Download",
      "selector": "a[href*='.pdf']",
      "delegate": "body",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-PDF",
          "ucsState": "non-pv",
          "eventName": "clickPDF",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CCTA-$[eventSource]",
          "interaction": "PDF Download - $[filename]"
        },
        "product": {
          "productCategory": "",
          "productName": "",
          "productPricing": "",
          "promoDetail": ""
        }
      },
      "variables": {
        "filename": {
          "type": "selector",
          "selector": "this",
          "method": "attr",
          "args": {
            "attr": "href",
            "match": "([\\w-_]+)(?=\\.pdf)"
          }
        }
      }
    },
    {
      "name": "TrackClickToEmail",
      "selector": "a[href^='mailto:']",
      "delegate": "body",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-CE",
          "ucsState": "non-pv",
          "eventName": "clickToEmail",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CE-$[eventSource]",
          "interaction": "$[ctaMailTo]"
        }
      },
      "variables": {
        "ctaMailTo": {
          "type": "selector",
          "selector": "this",
          "method": "attr",
          "args": {
            "attr": "href",
            "match": "((\\.?[\\w-]+)+)@(([\\w-]+\\.?)+)"
          }
        }
      }
    },
    {
      "name": "TrackAudioProgress",
      "selector": "audio",
      "events": "progressrangeupdate",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-AL",
          "ucsState": "non-pv",
          "eventName": "audioLaunch",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "AL-$[eventSource]",
          "interaction": "$[audioId]:$[audioProgress:0]% played"
        },
        "audio": {
          "audioName": "$[audioName]"
        },
        "user": {
          "bncId": "$[bncId:undefined]",
          "loggedStatus": "$[loggedStatus:false]"
        }
      },
      "variables": {
        "audioId": {
          "type": "selector",
          "selector": "this",
          "method": "prop",
          "args": {
            "prop": "currentSrc",
            "match": "(\\/content\\/dam\\/)([\\w-\\/\\.]+)"
          }
        },
        "audioProgress": {
          "type": "selector",
          "selector": "this",
          "method": "prop",
          "args": {
            "prop": "progressrange"
          }
        },
        "audioName": {
          "type": "selector",
          "selector": "body h1",
          "method": "text"
        }
      }
    },
    {
      "name": "TrackVideoLaunch",
      "selector": ".wrapper-vid",
      "events": "click",
      "delay": 100,
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-VL",
          "ucsState": "non-pv",
          "eventName": "videoLaunch",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "VL-$[eventSource]",
          "interaction": "$[videoId]"
        },
        "video": {
          "videoName": "$[videoName]"
        },
        "user": {
          "bncId": "$[bncId:undefined]",
          "loggedStatus": "$[loggedStatus:false]"
        }
      },
      "variables": {
        "videoId": {
          "type": "selector",
          "selector": "this",
          "child": "iframe",
          "method": "attr",
          "args": {
            "attr": "src",
            "match": "[^/?]+(?=\\?|$)"
          }
        },
        "videoName": {
          "type": "selector",
          "selector": "this",
          "parent": ".aem-Grid.aem-Grid--default--12, .aem-Grid.aem-Grid--default--4",
          "child": "h3",
          "method": "text"
        }
      }
    },
    {
      "name": "TrackOtherCTA_FundsWatchToggle",
      "selector": "button.nbi-watchlist-button",
      "delegate": ".nbi-funds.section",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-CCTA",
          "ucsState": "non-pv",
          "eventName": "clickCTA",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CCTA-$[eventSource]",
          "interaction": "$[fundStatus]$[fundCode]"
        },
        "product": {
          "productCategory": "",
          "productName": "",
          "productPricing": "",
          "promoDetail": ""
        }
      },
      "variables": {
        "fundStatus": {
          "type": "selector",
          "selector": "this",
          "child": "svg",
          "method": "attr",
          "args": {
            "attr": "class",
            "match": "watched|unwatched"
          },
          "lookup": true
        },
        "fundCode": {
          "type": "selector",
          "selector": "this",
          "method": "attr",
          "args": {
            "attr": "name",
            "match": "_[\\w]+"
          }
        }
      },
      "lookups": {
        "watched": "Watch",
        "unwatched": "Unwatch"
      }
    },
    {
      "name": "TrackOtherCTA_Signin_Launch",
      "selector": "a[href*='/secure'], a[href*='/login.html'], a[href*='/connexion.html']",
      "delegate": "body, .scrolled-container",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-CCTA",
          "ucsState": "non-pv",
          "eventName": "clickCTA",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CCTA-$[eventSource]",
          "interaction": "bninvest-signin-launch"
        },
        "product": {
          "productCategory": "",
          "productName": "",
          "productPricing": "",
          "promoDetail": ""
        }
      }
    },
    {
      "name": "TrackOtherCTA_Signin_Advisor_Submit",
      "selector": "form#loginForm",
      "delegate": "body",
      "events": "submit",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-FS",
          "ucsState": "non-pv",
          "eventName": "formSubmit",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "FS-$[eventSource]",
          "interaction": "bninvest-advisor-signin_submit"
        },
        "product": {
          "productCategory": "",
          "productName": "",
          "productPricing": "",
          "promoDetail": ""
        }
      }
    },
    {
      "name": "TrackOtherCTA_Signin_Client_Launch",
      "selector": "input#client-login-submit",
      "delegate": "body",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-CCTA",
          "ucsState": "non-pv",
          "eventName": "clickCTA",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CCTA-$[eventSource]",
          "interaction": "bninvest-client-signin_launch"
        },
        "product": {
          "productCategory": "",
          "productName": "",
          "productPricing": "",
          "promoDetail": ""
        }
      }
    },
    {
      "name": "TrackOtherCTA_SocialFollowLinkedIn",
      "selector": "a[href*='www.linkedin.com/company/banque-nationale-investissement/'], a[href*='www.linkedin.com/company/national-bank-investment/']",
      "delegate": "body",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-CCTA",
          "ucsState": "non-pv",
          "eventName": "clickCTA",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CCTA-$[eventSource]",
          "interaction": "Linkedin Follow"
        },
        "product": {
          "productCategory": "",
          "productName": "",
          "productPricing": "",
          "promoDetail": ""
        }
      }
    },
    {
      "name": "TrackOtherCTA_SocialFollowYouTube",
      "selector": "a[href*='www.youtube.com/channel/UCFjY02-4gKk1D04qdFXJi5A'], a[href*='www.youtube.com/channel/UCNTjx45xoAkoRt6u1NCmqFw']",
      "delegate": "body",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-CCTA",
          "ucsState": "non-pv",
          "eventName": "clickCTA",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "CCTA-$[eventSource]",
          "interaction": "Youtube Follow"
        },
        "product": {
          "productCategory": "",
          "productName": "",
          "productPricing": "",
          "promoDetail": ""
        }
      }
    },
    {
      "name": "TrackFormLaunch_InvestProfileQuestion",
      "selector": "a[href*='/content/forms/af/bni/fr/formulaires/investissement/questionnaire-profil-investisseur.html'], a[href*='/content/forms/af/bni/en/forms/investment/survey-investor-profiles.html']",
      "delegate": "body",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-FL",
          "ucsState": "non-pv",
          "eventName": "formLaunch",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "FL-$[eventSource]-aeminvestprofilequestion",
          "interaction": "$[ctaText]"
        },
        "product": {
          "productCategory": "BNI",
          "productName": "Prtflmeritage",
          "productPricing": "",
          "promoDetail": ""
        }
      }
    },
    {
      "name": "TrackFormLaunch_EnoncePolitPlacement",
      "selector": "a[href*='/content/forms/af/bni/fr/formulaires/investissement/questionnaire-epp.html'], a[href*='/content/forms/af/bni/en/forms/investment/survey-ips.html']",
      "delegate": "body",
      "events": "click",
      "payload": {
        "event": "trackEvent",
        "eventInfo": {
          "ucsId": "UCS-$[eventSource]-FL",
          "ucsState": "non-pv",
          "eventName": "formLaunch",
          "eventSource": "$[eventSource]",
          "eventTime": "$[timestamp]",
          "eventId": "FL-$[eventSource]-enoncePolitplacement",
          "interaction": "$[ctaText]"
        },
        "product": {
          "productCategory": "BNI",
          "productName": "Prtflmeritage",
          "productPricing": "",
          "promoDetail": ""
        }
      }
    }
  ],
  "listeners": [
    {
      "selector": "window",
      "events": "load",
      "trigger": {
        "selector": ".searchResult.section",
        "event": "search"
      }
    },
    {
      "selector": "audio",
      "events": "timeupdate",
      "trigger": {
        "selector": "this",
        "event": "progressrangeupdate",
        "args": {
          "ranges": [0, 25, 50, 75, 100]
        }
      }
    }
  ],
  "variables": {
    "phoneDisplayed": {
      "type": "selector",
      "selector": "a[href^='tel:']:lt(3)",
      "method": "attr",
      "args": {
        "attr": "href",
        "match": "\\+?[\\d- \\(\\)]+",
        "joinall": true
      }
    },
    "faqDisplay": {
      "type": "selector",
      "selector": "div[data-react-id*='floating'][data-react-id*='menu'] .floating-menu",
      "method": "exist"
    },
    "chatDisplay": {
      "type": "selector",
      "selector": "#bnc-chatbot",
      "method": "exist"
    },
    "loggedStatus": {
      "type": "cookie",
      "cookie": "secure_flag"
    },
    "ctaText": {
      "type": "selector",
      "selector": "this",
      "method": "text"
    }
  }
}
