Conditional content
Goal tracking
Dynamic data

Overview

Logic Tags allow you to easily add powerful conditional logic for content personalization with the click of a button.

Logic Tags are specially formatted snippets of code inserted into your WordPress posts or pages and replaced with dynamic content when the page is rendered.

When caching is active and Logic Hop Javascript Mode and Javascript Variables are enabled, Logic Tags are automatically converted to HTML and rendered after the page loads via AJAX.

Note: If you are using Gutenberg, the Logic Hop Page/Post Tool and Tool Palette are not available inside the editor. See the Logic Hop for Gutenberg guide for the block-editor workflow.

Conditional Logic Tags

Conditional Logic Tags display content when a Logic Hop Condition is true. They consist of two or more blocks of code placed before and after the content you want to display, and almost any content or HTML can sit between the blocks.

Logic Tags use a condition's WordPress slug, or ID, to specify which condition is evaluated. The easiest way to add them is the Logic Hop tool palette, which formats and inserts the tags automatically.

A basic conditional tag looks like: {{% if condition: today-is-friday %}} Happy Friday! {{% endif %}} — this shows "Happy Friday!" when the condition Today is Friday is true.

Conditional tags also support ELSE and ELSE IF statements, and adding an exclamation point in front of the slug (for example !today-is-friday) checks for when the condition is NOT met. Logic Tags are not just for text — any HTML such as images, videos, and forms can be wrapped, and multiple conditional tags can be added to a single page or post.

Nested Logic Tags

Nested Logic Tags are an experimental feature available in Logic Hop 3.2.2 and higher. Once enabled, review pages that contain Logic Tags to confirm everything renders as expected. A nested tag places a second conditional block inside the content of an outer condition, letting you combine rules such as Today is Friday with a UTM campaign check.

  • Open the Logic Hop Settings page
  • Check Enable Nested Logic Tags
  • Click Save Changes

Goal Logic Tags

Goal Logic Tags trigger a Logic Hop Goal when the page or post is loaded. The tag is a single block of code, written as {{{ goal: newsletter-signup }}}, and would trigger the Newsletter Signup goal each time the page loads. Multiple Goal Logic Tags can be added to a page or post.

Conditional Goal Logic Tags

Conditional Goal Logic Tags trigger a Logic Hop Goal when the page or post is loaded AND a specific condition is true. Written as a single block, {{{ goal: newsletter-signup | condition: today-is-friday }}} triggers the Newsletter Signup goal only when the page loads and the condition Today is Friday is true. Multiple conditional goal tags can be added to a page or post.

Data Logic Tags

Data Logic Tags display Logic Hop data to the user inside a page. They are a single block of code, such as {{{ var: Location.City }}}, which shows the city the current visitor is browsing from.

Logic Tags can be placed inside HTML elements and nested within Conditional Logic Tags. They also support additional attributes separated by the pipe character. For example, {{{ var: Query:firstname | case: upper | default: Partner | append: ! }}} displays the firstname query string in capitals with a trailing exclamation point, so ?firstname=wendy renders "Howdy WENDY!" and, with no query string present, "Howdy Partner!".

Data Logic Tag Parameters

Data Logic Tags accept the following parameters, combined and separated by the pipe character:

  • var — the variable name, for example Location.City
  • case — change the case of the output: lower, upper, first, or words
  • default — a fallback value used when no data exists
  • prepend — adds text in front of the data (use a non-breaking space for leading spaces)
  • append — adds text after the data

Using Logic Tags

The Logic Hop Tool Palette is the fastest way to add Logic Tags to your pages and posts, though you can also copy and paste them or write them directly. Follow these steps and your Logic Tag is ready for use.

  • Click the Logic Hop button
  • Select the Condition, Goal, or Data tab
  • Select your desired Logic Tag type
  • Click the corresponding Insert Logic Tag button
  • Adjust the Logic Tag within your content if necessary

Questions this page should answer

What are Logic Tags in Logic Hop?

Logic Tags are specially formatted snippets you add to WordPress posts and pages. They are replaced with dynamic, personalized content when the page renders, and can show conditional content, trigger goals, or output visitor data.

Do Logic Tags work with caching?

Yes. When caching is active and Logic Hop Javascript Mode and Javascript Variables are enabled, Logic Tags are converted to HTML and rendered after the page loads via AJAX.