CloudPages: Dynamic Redirect using a parameter in the URL

Getting the right message to the right person is what marketing is all about. The ideal campaign sends each person down a personalized path that speaks to their needs and wants at that time. We do this by using the data we have on that individual to decide what the desired experience is.

When it comes to emails, we are able to utilize AMPscript to dynamically select destinations based on the information we have at the time of email send. (We recently reviewed how to use AMPscript’s IF statement to accomplish this.)

There are use cases though that would benefit from this personalization but does not have as easy a solution. For instance, there are times that you need to provide a single link to work for everyone that encounters it.

This doesn’t mean we can’t personalize the experience, it just means we need to send the traffic through an interstitial page, also known as jump pages, that can sort the incoming traffic and redirect it to the desired landing page. While there are interstitial pages that will load and ask you to confirm information, such as asking you to confirm your age prior to showing you age restricted material, most of them simply redirect you another page. Check out our previous post on how to follow your links to see all the interstitial pages your traffic redirect through.

I decided to share this code as I recently needed it for one of my email campaigns. The email was sending them from their email to an external survey tool. Upon completion of the survey, I needed to send them to 1 of 3 landing pages based on data we knew about the user.

I was unable to use the survey tool to split my traffic as it did not have all the data to work with. Some information on the user we did not want to share due to personally identifiable information and info security guidelines. Other pieces of information change rapidly, and even if we had passed them via email to the survey, by the time they clicked on the survey and completed it – that data could be out of date.

So I set up a simple cloudpage that can pull information from the URL and then redirect the user to a landing page. Each user has a unique ID that we pass to the survey, that the survey tool uses to record the response in our Salesforce CRM instance, so I have set up my landing page to also look for this ID.

How to:

In the CloudPages Editor, create a collection and start a new landing page. You can choose to do code view in classic editor or use an HTML block in the new content builder editor within CloudPages. (Please note, we are in CloudPages for this example, using the content builder design functionality. This is separate from Content Builder – you can create Landing Pages in Content Builder but those cannot be edited via the CloudPages editor, and vice versa)

Paste the following into your HTML block or in your code view:

var @id
set @id = RequestParameter("ID")
if empty(@id) then ]%%
<meta http-equiv="refresh" content="0; URL=''">
<meta http-equiv="refresh" content="0; URL=''"

Once that is complete, publish and copy the URL.

If you paste just the URL, because there is no parameter being passed for ID, it should immediately redirect to google. (Please note- it can take upwards of 5 min for CloudPages to be live)

If you append your URL with “?ID=1” – it should redirect to the SFMCGeeks Homepage.

Remember, your IF statement can have multiple elseif’s and you can also have multiple actions within each step. Other actions you might include – updating or adding them to a data extension, looking up data from a data extension, & updating or looking up data from synchronized salesforce object.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.