Skip to main content
Contributor I
February 21, 2024
Solved

Dynamic Email Intro By Time of Day

  • February 21, 2024
  • 3 replies
  • 162 views

First time post/question. 

Looking to diversify an email templates written intro by time of day if possible?

Essentially say Good Morning, Afternoon or Evening based on the below time brackets. 

  • Good morning from 00:01 – 11:59  
  • Good afternoon from 12:00 – 18:00  
  • Good evening from 18:01 – 00:00
    This topic has been closed for replies.
    Best answer by KatherineB

    Hi @Lewis1994 Thanks for posting in the Klaviyo Community and what a great idea! 

     

    There is a great Community answer that details how you can accomplish this with some Django code added into your templates. 

    Here’s the post for reference: 

     

    3 replies

    KatherineB
    Partner - Platinum
    Champion & Partner
    February 21, 2024

    Hi @Lewis1994 Thanks for posting in the Klaviyo Community and what a great idea! 

     

    There is a great Community answer that details how you can accomplish this with some Django code added into your templates. 

    Here’s the post for reference: 

     

    Katherine - &BAM | 2023 Klaviyo Champion and Elite Partner
    Lewis1994Author
    Contributor I
    February 21, 2024

    Hey Katherine, perfect! Really appreciate this! 

    Lewis1994Author
    Contributor I
    February 27, 2024

    We’ve put this together so far which doesn’t seem to working. Are we missing anything/doing something wrong?

     

    <p>{% now "H" as hour_now %}</p>

     

    {% if hour_now >= 6 and hour_now < 12 %}
    <p>Good morning,</p>
    {% elif hour_now >= 12 and hour_now < 18 %}
    <p>Good afternoon,</p>
    {% else %}
    <p>Good evening,</p>
    {% endif %}

     

    <p>I noticed you didn&rsquo;t complete your trade in for the {{ event.AddedItemProductName }}&nbsp;</p>
    <p>As I want to make sure you get the best price for your phone, I can offer an extra &pound;5 on top of your quote, just come back to site and use the code COMEBACK5 at checkout.</p>
    <p>You can jump straight back to you order by clicking <a href="https://webuyanyphone.com/basket/{{ event.basket_token }}">here</a></p>
    <p>If there is anything else I can help with just let me know&nbsp;</p>
    <p>Many Thanks</p>
    <p>Sophie</p>
    <p>Customer Experience Team</p>