Add a custom Project JS code in PageSense
Project Javascript (JS) is an advanced project setting available in PageSense that lets you create customized Javascript code without having to change your native website's code. This JS code will execute as soon as the PageSense script loads on your page. Using this option, you can execute more advanced JS conditions in the experiments that run and depend on reusable variables, targeting conditions, and API calls, with ease and efficiency.
Common use cases for Project JavaScript include:
- Tracking unique custom events, such as newsletter subscription and scroll depth of users.
- Reusing custom modules, such as promotional banners and notification windows across multiple experiments.
- Running experiments on single-page apps that happen without reloading the page.
- Managing multiple analytics integrations on the same page.
- Targeting more than one experiment to the same audience.
To add your own Project JS code in PageSense:
1. Click Project Settings at the top right-corner and select Project JS.
2. Enter the custom Javascript that you want to add to your website within the text box and click Save.
For example, say you want to reuse the same 'coupon code' banner in multiple A/B experiment pages within your Project. In this case, you can write a Project JS code (as shown in the image below) that calls the function "window.showBanner()" in the 'Global or Variation JS code' of the A/B experiments in which you want to display the banner.
We hope this documentation helps make the process easy for you. Please feel free to reach out to us anytime by dropping an email to support@zohopagesense.com if you need more explanation or have any questions.