|
/ Documentation /CartFlows/Developer Docs/ Offers JS Triggers Shortcodes

Offers JS Triggers Shortcodes

In the CartFlows and CartFlows Pro, we’ve introduced new JavaScript variables (shortcodes) and triggers that can be used within custom JavaScript. These enhancements make it easier to access order and offer-related data for tracking, analytics, and custom automation requirements.

This feature is especially useful if you want to integrate third-party tracking tools, send data to external services, or run custom logic based on user actions within your flows.

Available JavaScript Variables

Below is the list of JavaScript variables that can be used on CartFlows pages.

Variables Available in CartFlows Free

The following variables are available in the free version of CartFlows:

  • {{order_id}}
  • {{txn_id}}
  • {{order_total}}

These variables can be used on all CartFlows steps except the Checkout page. This is because order-related values are generated only after the order has been successfully placed.

Variables Available in CartFlows Pro

The following variables are available with CartFlows Pro:

  • {{offer_product_name}}
  • {{offer_product_qty}}
  • {{offer_product_price}}

These variables are specific to offers and are available only on Upsell and Downsell steps, as they relate directly to the accepted or rejected offer.

Practical Use Case Example

You might be wondering how these variables can be used in real-world scenarios.

For example, if you want to trigger a custom Facebook Pixel or Google Analytics event on an Upsell or Downsell page and pass values such as the Order ID, Transaction ID, or Product ID, you can directly reference variables like {{order_id}}, {{txn_id}}, or {{product_id}} within your custom JavaScript. These values can then be sent dynamically to your tracking or analytics scripts.

JS Triggers for Upsell & Downsell Acceptance or Rejection

Along with JavaScript variables, CartFlows also provides built-in triggers that automatically run when an Upsell or Downsell offer is accepted or rejected.

This allows you to perform actions such as sending offer data to a CRM, triggering custom automation, or firing third-party tracking events based on the customer’s decision.

These script options are available only on Upsell and Downsell steps.

How to Add Offer Accepted or Rejected Scripts

Follow the steps below to add custom JavaScript for offer acceptance or rejection:

Step 1: Navigate to the CartFlows > Funnels menu in your WordPress dashboard.

Step 2: Click Edit on the funnel where you want to add the custom script.

CartFlows-Funnels-List

Step 3: Open the settings for the relevant Upsell or Downsell step.

Upsell Settings

Step 4: Open the Settings tab and locate the Custom Script option.

Upsell Custom Script Settings

Step 5: Add your custom JavaScript code in the Offer Accepted or Offer Rejected script field, depending on your requirement.

Upsell Offer Success Rejected Script

Step 6: Click Save to apply the changes.

JavaScript Variables Available in Offer Scripts

While adding offer accepted or rejected scripts, you can use the following variables to access offer and order-related data:

  • {{order_id}}
  • {{flow_id}}
  • {{step_id}}
  • {{product_id}}
  • {{variation_id}}
  • {{quantity}}
  • {{offer_type}}

Once added, these scripts will run automatically at the appropriate time. The Offer Accepted script will execute when an upsell or downsell is accepted, while the Offer Rejected script will run when the offer is declined.

This ensures your custom logic or tracking is executed precisely based on the customer’s action within the funnel.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page