Skip to content

Segments

Articles

V2 Logic Syntax: Quickstart

This guide provides a rapid overview of the most common syntax patterns used in Merch Jar Formulas for users familiar with filtering, scripting, or formula concepts.

Intro to Segments

Get acquainted with Merch Jar Segments, the powerful engine for creating advanced segments and automation logic using V2 syntax.

AI Copilot Overview

AI Copilot is an AI assistant that helps you turn plain-English requests and data into validated V2 Logic for Segments, making it faster and easier to design, refine, and safely deploy advanced automations.

Core Syntax Concepts

Understand the fundamental building blocks of Segments, including properties, operators, functions, and key definitions like Workflows.

The Segments Interface

Learn how to access the Segments interface and about its different components.

Getting Started: Writing Segments V2 Logic

Learn how to access the Formula Composer and write your first basic formula to filter your advertising data.

Using Time Periods

Explore the different ways to specify date ranges (Relative, Literal, Offset, Lifetime) required for time-based properties like clicks or sales.

Combining Conditions: Boolean Logic & Grouping

Learn how to use and, or, and parentheses () to create complex filter expressions with multiple conditions.‍

Math Operations

Discover how to use arithmetic operators (+, -, *, /) and the percent sign % for calculations within your Segments.

Understanding Datasets (Segment Sources)

Learn about the different data sources (Campaigns, Ad Groups, Keywords, etc.) you can select for your Segments and how they affect available properties.

Understanding Properties

Understand the concept of properties (time-based vs. static) and how they represent the data fields and settings used in Segments.

Understanding Functions

Get a high-level look at the available functions like now(), interval(), case(), and let that add dynamic capabilities to your Segments.‍

Defining Variables & Custom Properties

Dive into using the let keyword to define variables within your formula, which automatically create new calculated columns (Custom Properties) in your Segments.

Using Custom Properties in Workflows

Learn how to leverage the values from your Custom Properties (defined using let) to drive dynamic Workflow Actions like changing bids or budgets.

Conditional Logic

Master the case function to implement if/then/else style logic directly within your formulas based on specific conditions.

Adding Comments

Understand how to use single-line // and block /* */ comments to explain your Segments or temporarily disable code.‍

Scheduling Workflows

Control when a Workflow runs - once, on a recurring schedule, or on an advanced custom schedule - and set the time zone it runs in.

Workflows

Explore the available actions (like Change Bid, Set State) that can be automated based on your Formula Segments and learn about scheduling options.

Error Handling & Special Values

Learn how to interpret common syntax validation errors and understand how special values like NaN or division by zero are handled.

Example Segments & Use Cases

See practical examples demonstrating how to combine various syntax elements to achieve common analysis and optimization goals.

Upgrading from Recipes V1 Logic

Discover the key changes between Recipes V1 Logic and the new Segments V2 syntax.