0

I need to get the full page url on my Cloud page. When I try to do it through window.location.href then I get null. Is there any way using SSJS or AMPScript to get the full page url?

0

1 Answer 1

0

SSJS runs server side and wouldn't have the context of window.location. The only AMPscript functions that I can think of that would come close are RequestParameter (only returns parameters and not the URL) and HTTPRequestHeader (I don't believe Location is a valid header parameter). Given this the only way I can see to get this is to use client side javascript.

<!DOCTYPE html>
<html>
<body>
    <p>Page URL</p>
    <p id="url"></p>
</body>
<script>
  var pageUrl = window.location.href
 document.getElementById("url").innerHTML = pageUrl;
</script>
</html>
7
  • You are correct in your answer, but as I have marked the question as a duplicate, both the question and answers will be removed at some point. To save you from writing answers which might already exist, keep an eye on whether a question has been marked as duplicate. Feb 10, 2021 at 20:11
  • Lukas, where does it show that the post is a duplicate? Feb 10, 2021 at 20:41
  • Currently, you can only see this by looking at my comment. "Does this answer your question?" with (or without) a number left of it, and with a link to a similar answered question, is a good indication. The comment is a standard text added, when a question is marked as duplicate. Once you have sufficient reputation, you will also be able to see a "Close" link, next to Share, Edit, Follow. Feb 10, 2021 at 20:45
  • Makes sense! Thanks Lukas! Feb 10, 2021 at 20:51
  • @AaronCates AMPScript / RequestParameter("pageUrl") does the trick btw. Feb 11, 2021 at 7:40

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