Google Tag Manager

Forum Discussion

emily_wri's avatar
emily_wri
Supporter
2 months ago

Complex Canvas

We are trying to accomplish something in order to run a one month challenge and would love some assistance!

Basically, we will be asking people via in app message and content card to opt-in to the challenge throughout the month. If they click on a button, this will change a custom attribute value to true, which then triggers them to enter a canvas which sends them motivational content and updates.

Due to the complexity of triggering the messaging throughout the month and it needing to end on a specific date, I am looking to be able to filter the users based on when they entered the canvas. I was thinking there could be a way to do this based on a user update step at the very beginning of the canvas and update a new attribute to 'now's date. Then filter with an audience path to customize the messaging further down. 

However, I can't seem to be able to get that user update step to work. I've tried a few different liquid options, but no dice.

Has anyone done this previously and what's the mechanism you've used? I'm wondering if this would be a good place to use a canvas context step, but I can't seem to figure out exactly how to implement that in order to achieve what we're looking to do.

Any help is much appreciated!

4 Replies

  • Hi ​ emily_wri​ 

    You can handle this effectively using Canvas Context Variables. Updating a user attribute from inside a Canvas can work, but there is an important limitation: 

    A custom attribute is information saved on the user’s profile. It can change every time the user starts the Canvas again and the wait periods or any dependencies on the custom attribute will be messes up. 

    A context variable is information saved only for the user’s current run of the Canvas. If the user enters again later, they get a brand-new set of context variables, and the old ones stay untouched. (only if you do not update the variable again in a different context step)

    Imagine a coffee shop app.

    custom attribute is like a note on your customer account:

    “Favourite drink: Latte.”

    If the app updates this based on your last order, it might change the next time you come back and start a new order.

    A context variable is like your current order number:

    “Order #1042.”

    This number stays the same while you’re placing that order.

    If you leave and come back tomorrow to place a new order, you get a new order number, and yesterday’s number doesn’t change. It was only for that one visit.

    So:

    • Custom attribute = profile info that can change when you re-enter.
    • Context variable = session info; each time you enter, you get your own fresh set, and past ones are not affected.

    Ignore all of the above if you have disabled re-entry..haha. But I would still chose Context variables. 

    For this reason, once the Canvas is triggered, the very first step should be a Context Step. This ensures you capture the user’s entry information before anything else happens.

    Below are the two context variables that work well for a month-long challenge.

    1. Capture the user’s entry date with a Context Step

    Immediately after the Canvas trigger, add a Context Step.

    Create the first variable:

    Context Variable Name: entered_date

    Data Type: time

    Value : 

     {% comment %}
    --User entered the challenge -- The time is in UTC, change it to your need
    {% endcomment %}
    
    {{ "now" | date: "%Y-%m-%d %H:%M" }}

    This records the exact moment the user joined the challenge. Unlike a custom attribute, it will not update or change if the user triggers the entry logic a second time. You can reference this value in decision splits, audience paths, exit criteria, and message templates 

    This allows you to structure logic such as sending different content depending on the date they entered.

    2. Calculate how many days remain until the campaign end date

    If your challenge ends on a fixed date (for example, December 21), you can calculate the days remaining as soon as the user enters.

    In the same Context Step, create a second variable:

    Context Variable Name: days_till_campaign_end_date

    Data Type: Number

    Value:

    {% assign date_entered = "now" | date: "%Y-%m-%d %H:%M" %}
    
    {% comment %}
    -- Assign/Manipulate the campaign end date
    {% endcomment %}
    
     {% assign end_date = "2025-12-21 00:00" %} 
    {% assign entered_seconds = date_entered | date: "%s" %}
    {% assign end_seconds = end_date | date: "%s" %}
    {% assign diff_seconds = end_seconds | minus: entered_seconds %}
    {% assign diff_days = diff_seconds | divided_by: 86400 %}
    
    {{ diff_days }}

    This variable can be used for dynamic delays, for branching users into different paths based on how late they joined, or inside templates to adjust or abort certain messages. Because this calculation is stored in the Canvas context, it stays consistent no matter what the user does after entering.

    By making the Context Step the first step, you ensure that entry-specific data is captured immediately and remains reliable throughout the journey. Context Steps and dynamic delays provide clear, predictable ways to manage complex timing rules, challenge windows, late entrants, and final cutoff dates.

    I have attached few screenshots in the next comment for you to understand the above better. 

    If you can provide more info on the sending rules and wait periods etc., I can help refine the setup further. Do not hesitate! 

    Hope this helps! 

  • Defining Context Variables at the start of the canvas :

     

    How to use the context variables in audience path and delay steps: 

     

  • Hi,

    Let me restate what you are trying to do to make sure I understand the requirement.  You want people to be able to enter the canvas during the promotion period (say December), they can enter any time during that period, but at then end of the period (Jan 1), they can no longer enter the canvas?

    If the above is all you are looking for, then you can set your entry as action based, select the triggering actions (click in-app, click content card), and the set your entry window (in this case Dec 1-Dec 31).  I would also set it to not allow re-entry on the target audience tab.

    If the above works, then you just clone the canvas, update dates, triggers, and content for the next promotion period.