Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Warning: file_exists(): open_basedir restriction in effect. File(/var/www/efs/wp-content/plugins/memcached-is-your-friend/memcached-class-object-cache.php) is not within the allowed path(s): (/www/logichop_469/public:/www/logichop_469/mysqleditor:/www/logichop_469/web:/www/logichop_469/deploy:/www/logichop_469/deployment:/www/logichop_469/deployments:/www/logichop_469/tmp:/usr/share:/tmp:/dev/urandom) in /www/logichop_469/public/wp-content/object-cache.php on line 50

Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 554

Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 595

Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 535

Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 544

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-includes/comment-template.php on line 1745

Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 960

Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 980

Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 992

Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 1003

Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 151

Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 175

Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 164

Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 186

Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 138

Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 75

Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 89

Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 110

Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 127

Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 199

Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 133

Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 98

Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 79

Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 143

Deprecated: Return type of Gravity_Forms\Gravity_Forms\External_API\GF_API_Response::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/external-api/class-gf-api-response.php on line 179

Deprecated: version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/addon/class-gf-addon.php on line 5755

Deprecated: Return type of GF_Field::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 93

Deprecated: Return type of GF_Field::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 99

Deprecated: Return type of GF_Field::offsetSet($offset, $data) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 108

Deprecated: Return type of GF_Field::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 117

Warning: The magic method AffiliateWP_Allow_Own_Referrals::__wakeup() must have public visibility in /www/logichop_469/public/wp-content/plugins/affiliatewp-allow-own-referrals/includes/class-affiliatewp-allow-own-referrals.php on line 131

Deprecated: Creation of dynamic property Cookie_Law_Info_Cli_Policy_Generator::$plugin_name is deprecated in /www/logichop_469/public/wp-content/plugins/cookie-law-info/admin/modules/cli-policy-generator/cli-policy-generator.php on line 176

Deprecated: Use of "self" in callables is deprecated in /www/logichop_469/public/wp-content/plugins/cookie-law-info/includes/class-cookie-law-info.php on line 606

Warning: Private methods cannot be final as they are never overridden by other classes in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/packages/kirki-framework/compatibility/src/Control.php on line 67

Warning: Private methods cannot be final as they are never overridden by other classes in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/packages/kirki-framework/compatibility/src/Control.php on line 103

Deprecated: Creation of dynamic property Kirki\Compatibility\Framework::$modules is deprecated in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/kirki.php on line 68

Deprecated: Optional parameter $text declared before required parameter $cart_item_key is implicitly treated as a required parameter in /www/logichop_469/public/wp-content/plugins/logichop-subscription-conduit/logichop-subscription-conduit.php on line 323

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$customizations is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 136

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_subscribe_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 153

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_smtp_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 154

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_template_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 156

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_sms_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 157

Deprecated: Creation of dynamic property WOO_SL_functions::$query_vars is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-software-license/include/class.sl.functions.php on line 35

Deprecated: Creation of dynamic property WOO_SL::$licence is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-software-license/include/class.sl.php on line 21

Deprecated: Creation of dynamic property WCS_Retry_Admin::$setting_id is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-subscriptions/includes/payment-retry/admin/class-wcs-retry-admin.php on line 22

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/SchemaController.php on line 66

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/SchemaController.php on line 69

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/RoutesController.php on line 86

Deprecated: Creation of dynamic property wpdb::$payment_tokenmeta is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$order_itemmeta is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_product_meta_lookup is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_tax_rate_classes is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_reserved_stock is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 1705

Deprecated: Creation of dynamic property WooCommerce::$api is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/includes/class-woocommerce.php on line 554

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Internal/DownloadPermissionsAdjuster.php on line 157

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderTableMigrator.php on line 25

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderAddressTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderAddressTableMigrator.php on line 42

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderOpTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderOpTableMigrator.php on line 26

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostMetaToOrderMetaMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostMetaToOrderMetaMigrator.php on line 43
Logic Hop Javascript - Logic Hop

Logic Hop Javascript

Quick Reference

Overview

Logic Hop provides a number of Javascript functions which allow you to easily integrate Logic Hop data, conditions and goals into themes, plugins and with third party services.

Logic Hop’s Javascript Mode automatically renders Logic Tags and Conditional Widgets after page load to properly render personalized content on websites that employ caching.

Learn more about Logic Hop & caching.

Logic Hop Javascript Settings

Logic Hop Javascript Settings

Logic Hop Javascript Referrer & AJAX

Logic Hop’s Javascript functionality relies on AJAX. By default, the functionality is restricted to Javascript events called from your website – Calls from external websites are disabled.

The restriction is based on your domain name. The domain can be changed by visiting the Logic Hop settings and updating the Javascript Referrer field.

Note: Leaving the Javascript Referrer field blank will allow AJAX requests from any domains. It is recommended that you avoid allowing external requests unless necessary.

Access Variables with Javascript

Logic Hop data can be accessed via Javascript for use in themes and plugins.

Enable Javascript Variables

Javascript variable display is disabled by default. To enable, check the Enable Javascript Variable Display in the Logic Hop Settings.

NOTE: Javascript Variable Display must be enabled in the Logic Hop Settings to display data via Javascript.

Disable Specific Variables

When Javascript Variable Display is enabled all variables for the current user can be accessed during the active session via Javascript from the browser. In most instances this does not pose an issue, however with third party services this could expose data you wish to keep private, such as ConvertKit or Drip custom fields.

To disable individual variables, enter comma-separated variable names in the Disable Variables text area.

Note: Variables are only disabled from access via Javascript. Variables remain accessible within Logic Hop and via PHP.

View the full list of variables.

Get a Variable – logichop_var()

Pass a variable name into the __logichop_var( variable name )__ function. If the variable is set, the value will be returned. If the variable is not set a null value is returned.

The following code will return the Views data object.

var views = logichop_var( 'Views' );
console.log( views );

Note: Variables accessed via logichop_var() are available in real-time only when Javascript Mode is disabled. When Javascript Mode is enabled use the logichop_var_promise() function.

View the full list of variables.

Get a Variable – logichop_var_promise()

When Javascript Mode is enabled variables should be accessed using the logichop_var_promise() function to ensure the most recently updated value is returned.

Pass a variable name into the logichop_var_promise( variable name ) function. A data object is returned with the status and value of the variable in the following format:

{
  success: true
  data_var: "Views"
  value: 4
}

The following code will return the Views data object:

ES5

logichop_var_promise( 'Views' ).then(
  function ( data ) {
    console.log( data );
    var value = data.value;
  }
);

ESNEXT

logichop_var_promise( 'Views' ).then(
  ( data ) => {
    console.log( data );
    const { value } = data;
  }
);

Note: A promise polyfill is required to use Javascript promises in IE11.

Out Variables – logichop_session_display()

Stored variables can be viewed when the Logic Hop setting Session Output is set to Enable Session Display.

With Session Display enabled, enter the following code into the Javascript Console to view all stored variables:

logichop_session_display().then( ( data ) => console.log( data ) );

Note: Session Output should only be used during testing and development – Make sure to disable this option for production websites.

Evaluate Conditions with Javascript

Conditions can be evaluated with Javascript for use in themes and plugins. Pass a condition slug or ID into the __logichop_condition( slug, true callback, false callback )__ function. If the condition is met the true callback is executed. If the condition is not met the false callback is executed.

The following example the true callback is executed if the condition today-is-friday is met. The false callback is executed if the condition is not met.

logichop_condition( 'today-is-friday', my_true_callback, my_false_callback );

function my_true_callback () {
  console.log( 'today-is-friday returned TRUE' );
}

function my_false_callback () {
  console.log( 'today-is-friday returned FALSE' );
}

Set/Unset Goals with Javascript

Goals can be set and unset with Javascript for use in themes and plugins. Pass a goal slug or ID into the __logichop_goal() or logichop_goal_delete()__ function.

The following example sets the newsletter-signup goal for the current user:

logichop_goal( 'newsletter-signup' );

The following example deletes the newsletter-signup goal for the current user:

logichop_goal_delete( 'newsletter-signup' );

Conditional Goals

Goals can be set and unset with Javascript when a specific condition is met or not met.

logichop_goal( GOAL SLUG, CONDITION SLUG, CONDITION NOT MET );

The following code will set the newsletter-signup goal for the current user when the condition is-newsletter-thank-you-page is met:

logichop_goal( 'newsletter-signup', 'is-newsletter-thank-you-page' );

The following code will delete the unqualified-lead goal for the current user when the condition lead-score-less-than-10 is not met:

logichop_goal( 'unqualified-lead, 'lead-score-less-than-10', true );

Javascript Conditions

Logic Hop Javascript Conditions can be used to dynamically show and hide content after the page has loaded. Logic Tags are automatically formatted for post-load rendering when Javascript Mode is enabled, however you opt to add the formatted code manually if desired.

Javascript Conditions consist of HTML elements which can enclose almost any type of content. The HTML elements can be hidden prior to displaying by adding the class logichop-condition.

The following code will fade in to display Happy Friday! when the condition today-is-friday is met:

<div class="logichop-js logichop-condition" data-cid="today-is-friday" data-event="fadeIn">
  Happy Friday!
</div>

NOTE: Javascript Mode must be enabled in the Logic Hop Settings to display conditions via Javascript.

Javascript Condition Code

  • div
    • Opening HTML element
    • Can be any valid HTML element
      • Example: span, p, ul, h1, h2
  • class
    • Must include “logichop-js” to be evaluated
    • Additional classes can be added as needed
  • data-cid
    • WordPress slug or ID of the Logic Hop Condition
  • data-not
    • If true the content is displayed when the condition is not met
  • style
    • Set as “display: none;” to hide element on initial page load
    • Omit or leave blank to show element on initial page load
  • data-event
    • The jQuery Display Effect trigged for the HTML element if the Condition is met
    • Omit or set to “none” for no event
  • data-css-add
    • Adds CSS classes to the HTML element when the condition is successfully evaluated
    • One, or more CSS classes separated by spaces
      • Example: warning, highlight, active
    • Omit or set as “” to add no CSS classes
  • data-css-remove
    • Removes CSS classes from the HTML element when the condition is successfully evaluated
    • One, or more CSS classes separated by spaces
      • Example: warning, highlight, active
    • Omit or set as “” to remove no CSS classes
  • /div
    • Closing HTML element
    • Can be any valid HTML element
      • Example: /span, /p, /ul, /h1, /h2

Note: Your Javascript Condition can be applied to any type of HTML element. In the WordPress Editor, change the <div></div> tag as needed.

Javascript Variables

Javascript can be used to display data via AJAX after page load. Logic Tags are automatically formatted for post-load rendering when Javascript Mode is enabled, however you opt to add the formatted code manually if desired.

Javascript Variables consist of HTML elements and the variable value is inserted into the element after the page loads. The HTML elements are visible by default.

HTML Element Attributes

  • div
    • Opening HTML element
    • Can be any valid HTML element
      • Example: span, p, ul, h1, h2, input, img
  • class
    • Must include logichop-js to be evaluated
      • Additional classes can be added as needed
  • data-var
    • Logic Hop variable name
    • Required
  • data-type
    • replace
      • Element content replaced by variable using jQuery .html( var )
      • Default – When omitting data-type replace will be used
    • html
      • Element content replaced by variable using jQuery .html( var )
    • text
      • Element content replaced by variable using jQuery .text( var )
    • prepend
      • Variable prepended to element using jQuery .append( var )
    • append
      • Variable appended to element using jQuery .append( var )
  • data-event
    • The jQuery Display Effect trigged for the HTML element when the value loads
    • Omit or set to “none” for no event
  • data-case
    • Changes variable case
      • lower
        • Lowercase
      • upper
        • Uppercase
      • first
        • First word uppercase
        • words
        • First letter of every word uppercase
  • data-spaces
    • Replace spaces with character
      • Example: data-spaces=”-“
  • /div
    • Closing HTML element
    • Can be any valid HTML element
      • Example: /span, /p, /ul, /h1, /h2

Anchor Links, Images, & Inputs

For anchor links, images and form inputs Logic Hop will automatically update the HREF, SRC, or Value. The data-type attribute should be omitted for these elements.

Anchor Links

The value of the variable specified by data-var will replace the string #VAR# in the HREF attribute of the anchor.

The following code will properly render the UTM Code utm_content in the anchor link, replacing #VAR# with the value of utm_content:

<a href="https://stage.logichop.com/tutorial/#VAR#" data-var="utm_content">Click here to learn more</a>

Images

The value of the variable specified by data-var will replace the string #VAR# in the SRC attribute of the image.

The following code will properly render the UTM Code utm_content in the image source, replacing #VAR# with the value of utm_content in lowercase:

<img class="logichop-js" src="/wp-content/uploads/2019/10/industry_#VAR#.jpg" data-var="utm_content" data-case="lower">

Form Inputs

The value of the variable specified by data-var will replace the value of the input.

The following code will properly render the UTM Code utm_content as the input value:

<input class="logichop-js" type="text" name="content" value="" data-var="utm_content">

Examples

The following code will display the user’s city within a <span> tag after the page loads:

<span class="logichop-js" data-var="Location.City" data-type="html" data-event="show"></span>

The following code will display the user’s city within a <h1> tag after the page loads:

<h1 class="logichop-js" data-var="Location.City" data-type="html" data-event="append">Hello </h1>

The following code will display the user’s city within a text input tag after the page loads:

<input type="text" class="logichop-js" data-var="Location.City" data-type="input" value="">

NOTE: Javascript Mode and Javascript Variable Display must be enabled in the Logic Hop Settings to display data via Javascript.

Page Rendered Callback

Logic Hop provides the logichop_page_rendered(); function which is called after all Logic Hop Javascript events are completed.

The following function can be included in your Javascript and used to trigger custom events:

function logichop_page_rendered () {
  alert('Logic Hop page rendered callback');
}

Page Timeout Callback

Logic Hop provides the logichop_page_timeout(); function which is called if Logic Hop fails to load before the Anti-Flicker Timeout is reached. By default, this is set to 3 seconds. Learn more about the Anti-Flicker Timeout setting.

The following function can be included in your Javascript and used to trigger custom events in the unlikely event Logic Hop fails to load:

function logichop_page_timeout () {
  alert('Logic Hop page timeout callback');
}

Data Loaded Variable

With Javascript Mode enabled Logic Hop exposes the logichop.data.loaded boolean variable as another means to determine if Logic Hop data has been loaded. The value is false prior to data load and true once the data has been loaded.

Javascript Helper Classes

Logic Hop provides additional classes that can be used to minimize flicker when displaying conditions and loading data via Javascript. The classes hide the elements on the page using CSS and are displayed using jQuery after the page loads.

View the full details in the caching documentation.

jQuery Display Effects

Conditions are evaluated via AJAX after the page loads and, if a condition is met, the following events can be trigged to modify the HTML element:

  • Show
  • Hide
  • Toggle
  • Fade In
  • Fade Out
  • Fade Toggle
  • Slide Down
  • Slide Up
  • Slide Toggle