How to Redirect URL Links in Emails Based on Click Time - Nobuyuki Watanabe

Now, is it possible to redirect to different URL links based on the time when a link URL in an already sent email is clicked? For example, if clicked between 11:00 AM and 13:00 PM, display a specific page, and show an error message if clicked at other times.

When using AMPscript for email sending, AMPscript is loaded at the moment of email sending, and at that point, link URLs are already determined. Therefore, dynamic changes at the moment of clicking are not possible. To address this issue, you need to use CloudPages and create a mechanism on a landing page to redirect link URLs.

Let’s construct the following code on CloudPages:

%%[IF DateDiff('00:00',SystemDateToLocalDate(Now()),'h') >= 11
AND DateDiff('00:00',SystemDateToLocalDate(Now()),'h') < 13
OR DateDiff('00:00',SystemDateToLocalDate(Now()),'h') >= 35
AND DateDiff('00:00',SystemDateToLocalDate(Now()),'h') < 37 THEN]%%

<!--- From AM 11:00 to PM 13:00 --->
%%=Redirect('https://www.salesforce.com/')=%%

%%[ELSE]%%

<!--- From PM 13:00 to AM 11:00 --->
Oops! Something went wrong.

%%[ENDIF]%%

In this code, if clicked between 11:00 AM and 13:00 PM, a link to https://www.salesforce.com/ is provided; otherwise, an error message is displayed.

OR DateDiff(‘00:00’,SystemDateToLocalDate(Now()),’h’) >= 24
AND DateDiff(‘00:00’,SystemDateToLocalDate(Now()),’h’) < 36

*By the way, you may have some questions about the above section in the template, but consider this as a formality regarding SystemDateToLocalDate. As for your task, simply adding 24 hours should suffice.

As a reminder, the AMPscript used here is Redirect, and it should not be confused with another AMPscript called RedirectTo.

Now you have created a CloudPages URL that links to  https://www.salesforce.com/ if clicked between 11:00 AM and 13:00 PM. Feel free to incorporate this into the body of your email and give it a try for your email marketing campaign.

Comments

Popular posts from this blog

What are the different Content Blocks in SFMC ?

What is the different email-sending options in SFMC with examples?

Data Extension and List in SFMC