How to Add Pre/Post-Campaign JS/CSS

Last updated

Campaign JS/CSS is the code which runs across your website including the variations and control. You should add global JS/CSS when you want to implement a change across all your test pages including the control. To add campaign-level JS/CSS, click Campaign JS/CSS on the upper-right side of the editor.editor-58

Using VWO, you can add the following two types of JavaScript code snippets:

  • Post-campaign JS
  • Pre-campaign JS

Post-Campaign JS

This is the default mode when you select the Campaign JS/CSS option. Here, you can define JS code that you want VWO to execute before the campaign code executes for a page. Campaign or global JS are used for different functions such as the following:

  • Sending VWO campaign data to analytics tools
  • Custom conversion goal tracking
  • Defining a JS variable to capture the variation served to a visitor and then triggering the respective variation of a survey/notification widget

To add post-campaign JS, click the Settings icon next to Variation1 and then click Edit Code or click </> on VWO Visual Editor.editor-49

Under the Campaign JS/CSS option, enter JavaScript code you want to add to implement a change across all the variations and control of your test pages.editor-59

To add custom CSS to the website, select CSS > Include External Stylesheet.editor-52

Enter the URL to the CSS you want to include. To use JavaScript from the standard VWO library, select an option from the Quick Add list and then click Done.editor-53

Pre-Campaign

You can add JavaScript/CSS code to your campaign pages to indicate that VWO must run the code on the page before applying any changes to the variations. It allows you to trigger custom conversion goals without changing the code base of the entire website.

To add pre-campaign JS/CSS code, click Campaign JS/CSS in the upper-right corner of the code editor window and then select JavaScript > Define Pre-Campaign JS.editor-60

Add your pre-campaign JS code on the right panel of the window. On the left panel, enter the global/post-campaign JS code you want to execute after applying changes.editor-61
To apply the changes, click Done.

Was this article helpful?

Thanks for your feedback!
Please email us at support@vwo.com to tell us what you were looking for. We'll send the answer to your inbox.

Contact Us / Login

Product
Resources Home