Easily use custom SQL queries in your segments and campaigns.


What does this plugin do?

The Unlimited SQL plugin lets you:

  • Add custom SQL filters to segments (Segment Filter)
  • Run SQL queries as campaign actions (Campaign Action)
  • Use SQL queries as campaign conditions (Campaign Condition)
  • Test your SQL queries directly in the Mautic UI before using them

You can use placeholders like :contactId, :campaignId, and :eventId in your queries. The plugin will safely replace them with the right values for each contact or campaign step.


Features

  • Segment Filter: Add contacts to segments based on your own SQL logic.
    Example: Only include contacts with more than 5 page hits.
  • Campaign Action: Run a SQL query for every contact that reaches a campaign step.
    Example: Update an external CRM table when a contact hits a step.
  • Campaign Condition: Branch your campaign based on the result of a SQL query for a contact.
    Example: Check if a contact is in a VIP table and send them down a special path.
  • Testing Area: Select a contact and test your SQL query before saving.

See also: SQL Query Examples


How it works

  1. Create an SQL Entry
    Go to Unlimited SQL in the Mautic menu and create a new entry. Choose the type (Segment Filter, Campaign Action, or Campaign Condition), write your SQL, and save.

  2. Test your query
    Use the built-in testing area to select a contact and see if your query works as expected.

  3. Use in Segments or Campaigns

    • For segments: Add a filter of type “Unlimited SQL Filters” and select your SQL entry.
    • For campaigns: Add an action or condition and select your SQL entry.

Tip: Always use placeholders (:contactId, etc.) for security. The plugin will handle safe parameter binding.