1

I have functionality on a cloud page that depends on the CloudPage URL. I know how to Requestparameter(), but how do I get the entire URL using AMPscript or SSJS?

2
  • You mean the current cloud page URL? Dec 18, 2018 at 18:02
  • Yes, like "subdomain.site.com" or what ever url one would use to access the page: Had it been "subdomain.site.com?value=yes" I could use RequestParameter("value") to get the query string. But how do I get the complete url? The idea is to use the same code on multiple landing pages.
    – Tove
    Dec 18, 2018 at 19:11

2 Answers 2

7

You can get the current page url in AMPscript by using RequestParameter('PageURL'). This gives you the url dynamically without you having to hardcode.

Reference: Look at How to Fetch a html form's Post variables using AMPscript and create a record with the values in salesforce objects specifially @Eliot's answer He is using the below snippet to submit the form to the current page.

<form action="%%=RequestParameter('PAGEURL')=%%" method="post">

You can try debugging your currentURL in the page using inline variables like below.

<h1>%%=RequestParameter('PAGEURL')=%%</h1>
2
  • Ohh yes!! I totally had forgotten about this one. It does the trick. Thanks so much!
    – Tove
    Dec 18, 2018 at 19:37
  • @Tove You're welcome. Glad to help! Dec 18, 2018 at 19:40
3

Here's how to get the URL of current page (with parameters) in SSJS:

var url = Platform.Request.RequestURL();

Effectively, it's the equivalent of RequestParameter('PAGEURL') in AMPscript.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .