How to use different JS code for CCP v1 and CCP v2 with Web-Analytics Integration?
Modified on: Fri, 17 Nov 2023 12:08 PMOriginal Publishing Date:
2020-01-22
2020-01-22
Question:
It is possible to use the Web-analytics Integration feature to build-in a customer JavaScript code into the Customer Control Panel. But how to run different code for CCP v1 and CCP v2?
Answer:
This can be done by analysing the CCP URL. For example, the following approach can be used:
<script type="text/javascript">
var getLocation = function(href) {var l = document.createElement("a"); l.href = href; return l;};
var u = getLocation(window.location.href;);
i = u.pathname.split('/');
if (i[1] == 'ccp'){
<paste the CCP v2 code here>
}
else {
<paste CCP v1 code here>
}
</script>
The customer JS code is placed to OA > System > Settings > Brands > YourBrand > Web-Analytics Integration.