Tracking5 min read
Track and surface your prospects’ first navigation page in Webflow

Video
| Step | Webflow element | Action |
|---|---|---|
| 1 | Head of each page | Add the script to capture the first page |
| 2 | Form | Add a hidden field to store the URL |
| 3 | Hidden input | Add a unique ID (e.g. firstpage) |
| 4 | Head or Body | Inject the value into the field |
In this episode, Sandro, cofounder of the Gemeos Webflow agency, shows you how to track and capture the first page your prospects visit in Webflow
1. Add the custom code to capture the first page and store it in session
Add this custom code in the head of each of your landing pages
<script>
// Declare the firstPage variable for new users and store it in session
var firstPage;
if (!sessionStorage.getItem("firstPage")) {
firstPage = window.location.pathname;
sessionStorage.setItem("firstPage", firstPage);
} else {
firstPage = sessionStorage.getItem("firstPage");
}
</script>2. Add a field to your form to pass along the stored value
Make sure to set these fields to display: none. Your prospects don't need to see them, and it could hurt your conversion rate.

3. Add an ID to your form field

4. Add the custom code to display the first page URL in your form field
Make sure to replace "firstpage" with the ID you set earlier
<script>
// Get the HTML element corresponding to the form field
var firstPageField = document.getElementById("firstpage");
// Update the HTML element value to display firstPage
firstPageField.value = firstPage;
</script>5. Publish your site and test the result



