This article covers the following:
Overview
Wingify allows you to configure custom JavaScript and CSS for your campaigns in the visual editor. This capability provides extended functionality beyond standard visual changes. It is particularly useful for advanced data tracking or integrating with third-party tools. You can configure two types of code snippets in the Campaign code tab:
- Post-campaign code: Executes after Wingify applies the campaign changes to the page. This is the default mode.
- Pre-campaign code: Executes on the page before Wingify applies any visual changes or variations.
Common use cases of configuring campaign-level pre/post JavaScript include:
- Send Wingify campaign data to third-party analytics tools (Post-campaign JS).
- Capture the variation served to a visitor and trigger a corresponding survey or notification widget.
- Apply global CSS or include external stylesheets across all variations in a single step.
The following section explains how to access the campaign code editor to configure pre-campaign and post-campaign JavaScript
Access Campaign Code
To access the Campaign Code editor:
- Open your campaign in the Visual Editor.
- From the mode switcher in the top bar, select the Code mode.
- From the top left, navigate to the Campaign code tab.
The code editor panel opens, where you can add both post-campaign and pre-campaign JavaScript.
Add Post-Campaign Code
To add post-campaign code:
- Navigate to the JavaScript tab nested under the Campaign code tab.
- Enter the script you want to execute after the campaign changes apply.
- Select Done.
- [Optional] Select the Wait for DOM ready checkbox if you want the JavaScript to execute only after the DOM is fully loaded.
Note: Note: Post-campaign JavaScript runs only on the campaign URLs listed under the Configuration > Pages section of your test setup.
Add Pre-Campaign Code
Pre-campaign code runs before Wingify applies any variation changes. Use pre-campaign code to define functions or track events on pages without changing the website’s codebase. This is useful when you need to define functions or track events on pages without changing the website’s codebase.
To add pre-campaign code:
- Navigate to the JavaScript tab nested under the Campaign code.
- In the top-right corner, click Define Pre-campaign JS
- Enter your script in the Pre-Campaign JS panel on the right side of the window.
- Select Done.
Note: Pre-campaign JavaScript runs on:
- URLs configured in the Pages section of the campaign setup.
- URLs configured in the Page URL property of Custom Events used in campaign metrics
You can also add external CSS libraries to your campaign.
Add Custom CSS
To add custom CSS for your campaign:
- Navigate to the CSS tab nested under the Campaign code tab.
- From More options , select Include External Stylesheet
- In the Include External Stylesheet dialog, enter the URL of your CSS file.
- To use a commonly known library, select it from the Quick Add dropdown (options include Bootstrap, Foundation, and Animate.css).
- After selecting a library, click Done. Your custom CSS is added.
Need more help?
For further assistance or more information, contact Wingify Support.