简体   繁体   中英

Obtain Original First Entry URL Href Hit While User Keeps Navigating between Different Pages

Background: I have a website, say https://example.com , which has different pages. Eg user firstly came to the site with URL https://example.com/page-a?utm=google , then user continue browsing other pages eg /page-b, /page-c.

Problem: In other pages, eg, /page-b, how can I know the user's original first hit URL (which is https://example.com/page-a?utm=google ). Can I obtain from the browser easily?

Thank you very much.

I have investigated this one for quick a bit. And I think this trick can help the case. Apply the session Storage logic to each page, so add the following code to each page of the website:

<script>
  if (!sessionStorage.getItem("entryURL")) {
    sessionStorage.setItem("entryURL", document.location.href);
  }
</script>

Then in each page, can access from sessionStorage.getItem("entryURL")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM