If you want to send a campaign every other week, you can use Jinja to check whether the current week number is odd or even. This can be useful when you want one scenario to run weekly, but only allow customers to continue through the flow on alternating weeks.
When to use this approach
This approach is useful when you want to:
- Send a newsletter every second week
- Alternate between two campaign variants on different weeks
- Skip one weekly run and send on the next one
This logic is based on the calendar week number, not on a custom start date. In practice, that means the condition checks whether the current week is odd or even, rather than counting a rolling 14-day window from when the scenario started.
Solution
Use the following Jinja in a condition node:
{% set week = time | from_timestamp('%W') %}
{% set remainder = week %2 %}
{% if remainder == 0 %}
True
{% else %}
False
{% endif %}How it works
This code gets the current week number, divides it by 2, and checks the remainder.
- If the remainder is
0, the condition returnsTrue, which means the current week is even. - If the remainder is not
0, the condition returnsFalse, which means the current week is odd.
In scenario conditions, rendered Jinja values such as True and False are evaluated as boolean results.
How to use it in a scenario
- Create a scenario with a weekly trigger.
- Add any standard filters you need, such as consent, email availability, or audience eligibility.
- Add a condition node and switch to the code editor.
- Paste the Jinja code into the condition.
- Route customers through the send path only when the condition returns
True.
Example: send on even weeks only
If you want to send only in even weeks, use:
{% set week = time | from_timestamp('%W') %}
{% set remainder = week %2 %}
{% if remainder == 0 %}
True
{% else %}
False
{% endif %}With this setup, customers continue only during even-numbered weeks.
Example: send on odd weeks only
If you want to send only in odd weeks, reverse the condition:
{% set week = time | from_timestamp('%W') | int %}
{% set remainder = week % 2 %}
{% if remainder != 0 %}
True
{% else %}
False
{% endif %}With this version, customers continue only during odd-numbered weeks.
Note: This example checks the week number of the year, not the week of the month. For example, a date may fall in the third week of a month, but still return an even week number for the year. If you want to build a condition based on the week within a month, you need a different approach.
Testing recommendation
Before using the condition in a live scenario, test it with a test profile in a safe environment and confirm whether the current week should return True or False. This helps verify that the campaign is aligned with the expected sending week.
Tip
For more advanced scheduling based on a specific weekday occurrence in a month, see How to trigger a scenario for a specific first day of the week in the month.