Developers: Working with PHP Scripts

Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy but don’t provide support for code customizations or third-party development.

Sometimes, you’d like to silently post data to an external URL after a popup closes, display content fetched from the database, or modify a box option before it’s displayed to the visitor.

With the PHP Scripts feature, all the aforementioned scenarios are now possible. Let’s see how that works.

FireBox fires certain events during runtime and enables you to execute PHP when these events occur, just like in the Actions section, but this time, the events are fired on the server side. With the proper knowledge of PHP, you can do just about anything and customize the behavior of the popup to fit your needs.

Prerequisites

Before using PHP Scripts, you must first enable them under FireBox > Settings > Advanced > Enable PHP Scripts.

Events

The PHP Scripts area consists of five sections triggered by certain events.

On Before Render

The PHP script added in this area is executed after the campaign passes the Display Conditions checks and before the campaign’s layout is rendered. The main focus in this area is the $campaign (Object) variable, which contains the campaign’s settings.

On After Render

The PHP script added in this area is executed after the campaign’s layout is rendered. The main focus in this area is the $campaignLayout (String) variable, which contains the campaign’s final HTML. To access the campaign settings, use the $campaign (Object) variable. 

On Open

The PHP script added to this area is executed every time the campaign opens. The main focus in this area is the $campaign (Object) variable, which contains the campaign’s settings.

On Close

The PHP script added in this area is executed every time the campaign is closed. The main focus in this area is the $campaign (Object) variable, which contains the campaign’s settings.

On Form Success

The PHP script added in this area is executed every time a visitor successfully submits the FireBox form block in your campaign. The main focus in this area is the $campaign (Object) variable, which contains the campaign’s settings, $values (Array), which contains the submitted form field values, and $submission (Array), which includes the submission details.

Was this helpful?