How to Create Logic Hop Conditions

The Logic Builder is a powerful, but easy-to-use tool for creating Conditions, the custom algorithms which provide the core Logic Hop functionality.

Conditions are used by Logic Hop to perform actions such as displaying content, setting goals and redirecting visitors to different pages.

Understanding Logic Hop Conditions

Conditions consist of one or more statements which evaluate to either true or false. When a Condition is true Logic Hop can perform an action.

Conditional statements can be thought of as “questions” answered by Logic Hop. The question consists of one or more “values” which are compared by a “comparison operator”. The “answer” to a Condition is either true or false which can be thought of as “yes” or “no” respectively.

For example:

If the Day of the Week is Equal to Friday

In the above Condition, “Day of the Week” and “Friday” are the values. “Equal to” is the comparison operator.

Click here for a full list of Condition Types and Comparison Operators.

Anatomy of a Condition

  • Condition Title
    • Title
    • Used to generate Condition Slug – Example: today-is-friday
  • Condition Description
    • Description
    • Describes Condition functionality
  • Conditional Statements
  • Logic Tags
    • Logic Tag block to copy & paste into WordPress content
  • Enables Conditional CSS
    • Enables Conditional CSS and Conditional Not CSS – Disabled by default
  • CSS Classes
    • CSS Classes to copy & paste into WordPress content

Creating a Condition

Condition Builder - Today is Friday

Step 1

Click Conditions under the Logic Hop menu in your WordPress Dashboard.

Step 2

Click “Add New” to create a new Condition or click the title of an existing Condition to edit.

Step 3

Enter a title and description for the Condition.

Titles and descriptions are for your use within the WordPress Dashboard. It is best to use short, descriptive titles such as “Today is Friday” or “User is Logged In.

Step 4

Within the Conditional Statements section, select a Condition Type.

Example: Day of the Week

Step 5

Select an Comparison Operator.

Example: Equal To

Step 6

Select a Value.

Example: Friday

Step 4

Click Publish.

Congratulations! Your Condition is now ready for use.

Click here to learn how to use Conditions with Pages & Posts.

Please Note: Similar to WordPress Post and Page titles, the Condition title becomes the “slug” for your Condition. If you are using Conditional CSS or Javascript Tracking, this “slug” may be visible in the source code of your page. For example, a Condition titled “Today is Friday” may appear as a CSS class with the name “.today-is-friday”.

Creating a Multi-Statement Condition

Multi-Statement Conditions consist of two or more Conditional Statement blocks. Each block adds another “question” to the Condition. The blocks can be structure as And statements or Or statements.

And statements require that all of the Conditional Statement blocks be true.

Or statements require that only one of the Conditional Statement blocks be true.

Condition Builder - Multiple Conditions

Step 1

After creating an initial Condition, click the “+” button to add a new Conditional Statement block.

Step 2

Select the Statement Block Type.

Example: And

Step 3

Select a Condition Type.

Example: User Is

Step 4

Select an Comparison Operator.

Example: Logged In

Step 5

Click Update.

Congratulations! Your multi-statement Condition is now ready for use.

Note: To remove a Conditional Statement block, click the “Remove” link in the lower right corner of the block you wish to delete.

Deleting a Condition

Step 1

Click Conditions under the Logic Hop menu in your WordPress Dashboard.

Step 2

Click “Trash” under the title of the Condition you’d like to delete.

Evaluate Conditions with PHP

Logic Hop Conditions can be evaluated directly via PHP for use in themes and plugins. Pass a Condition ID into the $logichop->get_condition() function. If the Condition is met, true is returned, if it is not met, false is returned.

global $logichop;

$result = $logichop->get_condition(123);

The above example returns true if Condition ID 123 is met or false if it is not met.