Skip to content

Merge tags and templates

Merge tags let a form or message show information that is only known at that moment, such as the entry ID or the page the visitor came from. CampaignSuite adds its own tags to the Gravity Forms merge tag picker. It also adds a simple template language (Blade syntax) for conditions and calculated text.

Wherever Gravity Forms offers the merge tag picker, such as in notifications, confirmations and feeds, you can choose from these tags:

Tag Shows
{cs:form_id} The form ID
{cs:entry_id} The entry ID
{cs:source_url} The address of the page the form was submitted on
{cs:originating_post_id}, {cs:originating_post_slug}, {cs:originating_post_title} The page or post that contains the form
{cs:originating_post_campaign_code} The Campaign Code of that page or post
{cs:entry_date_time}, {cs:entry_date}, {cs:entry_time} When the entry was made
{cs:entry_generic_hash} A unique, hard-to-guess code for the entry
{cs:entry_debug_mode} Whether debug was on
{cs:one_click_link} The path of the one-click link used, if any

{cs:entry_generic_hash} is a random code that is created once for each entry. Because it can’t be guessed from another entry’s code, it works well as a reference or in a link where you don’t want to show the entry ID.

A FinDock form adds these tags to the picker:

Tag Shows
{cs:csentry_id} The CampaignSuite entry or payment ID
{cs:payment_intent_id} The FinDock payment intent ID
{cs:payment_intent_status} The status of the payment intent
{cs:contact_id} The Salesforce contact ID (not offered when only person accounts are used)
{cs:account_id} The Salesforce account ID

When the form is marked Financial form, you also get:

Tag Shows
{cs:destination_id} The destination the payment went to
{cs:onetime_id} The FinDock one-time payment ID
{cs:recurring_id} The FinDock recurring payment ID
{cs:payment_status} The payment status

Values that are only known after the payment, such as the status, stay empty until FinDock has reported back. So use them in notifications for FinDock moments rather than in the first confirmation.

You can write small templates, for example to show different text depending on an answer. They look like this:

  • Show a value: {{ $input_1 }}
  • A condition: @if($input_1 == "yes") Thank you for joining! @else We will stay in touch. @endif
  • A choice: @switch($input_2) @case("a") Text A @break @default Other @endswitch
  • A loop: @foreach($items as $item) {{ $item }} @endforeach

$input_1 is the value of the field with ID 1. For fields with several inputs, such as a name or address, $input_1_3 is input 3 of field 1. The picker has ready-made snippets named Blade if statement template, Blade else-if statement template, Blade switch statement template, Blade foreach-loop template, Blade for-loop template and Blade variable template, which you pick and then adjust.

To keep templates safe, only a limited set of functions is allowed. You can use count, in_array, strtolower, strtoupper, ucfirst, trim, str_replace, substr, strlen, implode, explode, sprintf, number_format, round, min, max and date, among others. Anything else, raw PHP included, is refused.

When a template can’t run, a short error message appears where your text would be, for example “Blade template not allowed” followed by the reason. Visitors can see it, so test your templates with the form preview. A variable that doesn’t exist is shown as empty.

  • In field default values, for example a hidden field with a calculated value, the value is calculated when the form is submitted. If the visitor changed the field or it was prefilled, the value is kept as it is.
  • HTML fields, field labels and descriptions are calculated every time the form is shown. They can use values the visitor already filled in on an earlier page, and values from prefill or a one-click link.
  • Notifications, confirmations and feeds are calculated with the values of the entry. A merge tag inside a template doesn’t work there, so use $input_1 instead of {Name:1}.

This confirmation uses merge tags and a template together:

A confirmation message with merge tags for the name, total, reference and email, and an if-else template on the frequency

Values that visitors type are only ever used as data, never as part of the template, so a visitor can’t add a template of their own.

  • Keep templates short and test them with the form preview.
  • Use a hidden field with a template to prepare a value that you map in a feed.
  • If text looks wrong or shows an error message, check the quotes and the closing @endif, @endforeach or @endswitch.