Is there a way to track in a SalesForce Marketing Cloud landing page if a user has previously viewed the page.

Scenario: directing a user to a landing page from an email. On the off chance that the user visits the page again from the email, I'd like to redirect them to another page. Is this possible in SFMC? How would I go about doing that?


There are several different approaches to this. You could query the Click Data View, but considering that data is only retained for 6 months, it could be safer to track clicks yourself, in a DE.

The following code is a highly simplified (and functional) example.

Firstly, create a DE named 'Page Visits' with a single field named 'Subscriber Key'.

Next, in your email, include the following inline AMPscript function as your href attribute to your page, where 123 is the value of the CloudPage identifier (accessible from the Page Properties in the CloudPages Collection) of the CloudPage that you are using (refer to my video if you need to locate this value).

<a href="%%=CloudPagesURL(123)=%%">link to page</a>

Now, include the following code in your CloudPage:

<!doctype html>
 <meta charset="utf-8">
 <title>My Landing Page</title>

%%[ if RowCount(LookupRows('Page Visits','Subscriber Key', _subscriberKey)) > 0 then ]%%
   InsertData('Page Visits','Subscriber Key', _subscriberKey)


<h1>Thanks for visiting!</h1>

This code will only display the page if the page has not previously been visited by the Subscriber, but redirect to a different page if they have visited it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.