Skip to main content

TRAC: How to fix and correctly structure your Boolean query

4 common errors stopping your boolean from validating and how to fix them


1. Connecting source operators (PINTEREST, TWITCH) with OR and parentheses

When adding channel specific operators, such as PINTEREST or TWITCH to your main search logic, follow these essential rules:

  • Use the OR operator: Always place an OR operator before specifying your source specific keywords (OR PINTEREST, OR TWITCH) to connect them to your main keyword Boolean.

  • Enclose sections in parentheses:

    1. Enclose your main keyword section in its own set of parentheses.

    2. Enclose each platform section in its own set of parentheses.

    3. Wrap the entire combined block (main keywords + platform sections) inside a master set of outer parentheses.

  • Simple words and conjunctions: If you see the below error message this is flagging that PINTEREST and TWITCH only allow simple words and conjunctions. This means that if you are applying multiple AND keywords, you need to specify the combinations separately. See example here:

Incorrect: OR PINTEREST(Puma AND (shoes OR sneakers OR trainers))

Correct: OR PINTEREST((Puma AND shoes) OR (Puma AND sneakers) OR (Puma AND trainers))

Taking the above rules into account, here is a Boolean comparison:

Incorrect: (Puma AND (shoes OR sneakers OR trainers) PINTEREST(Puma AND (shoes OR sneakers OR trainers)

Correct: ((Puma AND (shoes OR sneakers OR trainers)) OR PINTEREST((Puma AND shoes) OR (Puma AND sneakers) OR (Puma AND trainers)))


2. Proximity operator (NEAR) and historical data

  • Avoid using unnecessary parentheses around individual terms paired with NEAR.

Incorrect: ((Puma NEAR/3 sponsorship)) OR ((Puma NEAR/3 collaboration))

Correct: Puma NEAR/3 sponsorship OR ((Puma OR Nike) NEAR/3 (collaboration OR paid))

  • Historical data Limitation: The NEAR operator works for real-time data tracking only. Historical data cannot be launched when the NEAR operator is present in your Boolean.

Workaround Steps if you need historical data:

  1. Replace NEAR with AND in your query before launching your historical data. Example: change Puma NEAR/3 sponsorship to Puma AND sponsorship

  2. Launch and complete your historical data request.

  3. Once the historical data fetch is complete, update your Boolean query back to NEAR to continue capturing ongoing realtime data.


3. Global Filters Order and Single-Instance Rules

  • Global filters must always be placed at the very end of your Boolean query, outside a master set of parentheses containing your main keywords. Additionally, specific global operators must only appear once per query to prevent conflicts:

  • Only 1 AND NOT parentheses: Combine all exclusions into a single AND NOT (...) grouping instead of scattering multiple AND NOT statements.

  • Only 1 LOCATION operator: Define all target location codes in a single AND LOCATION (...) parentheses.

  • Only 1 LANG operator: Specify language parameters in a single AND LANG (...) parentheses.

  • Only 1 RT operator: Place retweet exclusions (AND NOT RT) once at the end of your boolean query.

Recommended query structure: ((Main Keywords) OR PINTEREST(...) OR TWITCH(...)) AND NOT (...) AND LOCATION (...) AND LANG (...) AND NOT RT


4. Correct use of Site Exclusions (SITE)

When excluding websites, write AND NOT SITE once followed by the URLs separated by OR inside parentheses. Do not repeat SITE before each individual URL.

Incorrect: AND NOT (SITE(https://www.dailystar.co.uk) OR SITE(https://www.dailymail.com))


Taking all 4 learnings from this article, here is a structured boolean example:

Puma Brand Campaign:

((Puma OR "Puma Sportswear" OR "Puma Shoes" OR "Puma Sneakers" OR "Puma Apparel" OR "Puma Running" OR #Puma OR (Puma NEAR/3 Running))

OR PINTEREST ((Puma AND shoes) OR (Puma AND sneakers) OR (Puma AND trainers) OR (Puma AND running)))

AND NOT (cougar OR panther OR "mountain lion" OR "wild cat")

AND LOCATION (US OR GB OR DE OR FR OR JP OR AU)

AND LANG (en OR de)

AND NOT RT

Did this answer your question?