Skip to main content

Integration QueriesNew in 5.10.8+

The Integration query allows you to access some of the properties of integrations on the frontend via Twig.

Overview

The Integration query is consistently constructed in the same manner. The first parameter must include the form handle or ID, while the second parameter must contain the integration handle.

A basic implementation of the Integration query would look like this:

{{ freeform.integration("myFormHandle", "post-forwarding").url }}

Accessing integrations

To access integrations, you need to specify the handle of the integration that you configured in its settings. Please note that not all features of regular integrations such as Salesforce and Mailchimp are available. Generally, this feature is intended for use with Single integrations.

In the case of Single integrations, those handles remain hidden but are always the same:

Google Tag Manager

The following properties are available via google-tag-manager:

  • enabled
  • containerId
  • eventName

Honeypot

The following properties are available via honeypot:

  • enabled
  • inputName
  • errorMessage

Javascript Test

The following properties are available via javascript-test:

  • enabled
  • inputName
  • errorMessage

Post Forwarding

The following properties are available via post-forwarding:

  • enabled
  • url
  • errorTrigger
  • sendFiles

Examples

Single Property

One of the most basic examples might look something like this:

{% set form = freeform.form("myFormHandle") %}

{{ freeform.integration(form, "post-forwarding").url }}

Multiple Properties

If you need to access multiple properties from a specific integration, your code might look like this:

{% set form = freeform.form("myFormHandle") %}

{% set postForwarding = freeform.integration(form, 'post-forwarding') %}
<ul>
{% if postForwarding %}
<li>{{ postForwarding.url|default('') }}</li>
<li>{{ postForwarding.errorTrigger|default('') }}</li>
<li>{{ postForwarding.sendFiles|default('') }}</li>
{% endif %}
</ul>

Multiple Integrations

If you need to access multiple properties from multiple integrations, you can streamline your code like this:

{% set form = freeform.form("myFormHandle") %}

{% set integrations = [
{ handle: 'post-forwarding', fields: ['enabled', 'url', 'errorTrigger', 'sendFiles'] },
{ handle: 'honeypot', fields: ['enabled', 'inputName', 'errorMessage'] },
{ handle: 'javascript-test', fields: ['enabled', 'inputName', 'errorMessage'] },
{ handle: 'google-tag-manager', fields: ['enabled', 'containerId', 'eventName'] },
] %}

<ul>
{% for integration in integrations %}
{% set instance = freeform.integration(form, integration.handle) %}
{% if instance %}
<li>
<strong>{{ integration.handle }}</strong>:
{{ integration.fields
|map(field => attribute(instance, field)|default(''))
|filter(v => v is not empty)
|join(', ')
}}
</li>
{% endif %}
{% endfor %}
</ul>