Google Analytics 4 is more of a sandbox than Universal Analytics was. With multiple scopes (hit, session, product) disappearing, some very popular features are lacking in GA4. In this blog post, I will explain how you can get Landing Page back in Google Analytics 4.
In essence, to get landing page as a dimension in Google Analytics 4, you need to make sure that every time a hit is captured, the landing page is sent alongside it. This way, every event, and conversion can be attributed to a landing page. Just like in the good old days.
The easiest way to do this is by configuring a variable and your GA4 event tag(s) via Google Tag Manager.
The GTM variable
In Google Tag Manager, go to Variables > New and select a Custom JavaScript variable. Paste the following code.
The code will check if the URL contains a UTM parameters or if a ‘landing_page’ cookie is present. If the cookie is not present or if a UTM parameter is in the URL, the ‘landing_page’ cookie is put in place. This cookie contains the page path where the session started.
function() { function getCookie(name) { var dc = document.cookie; var prefix = name + '='; var begin = dc.indexOf('; ' + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else { begin += 2; var end = document.cookie.indexOf(';', begin); if (end == -1) { end = dc.length; } } return decodeURI(dc.substring(begin + prefix.length, end)); } if (getCookie('landing_page') == null || document.location.search.match(/utm\_(campaign|source|medium)/)) { var cookieName = 'landing_page'; var cookieValue = document.location.pathname; var cookiePath = '/'; var expirationTime = 1800 expirationTime = expirationTime * 1000; var date = new Date(); var dateTimeNow = date.getTime(); date.setTime(dateTimeNow + expirationTime); var expirationTime = date.toUTCString(); document.cookie = cookieName+'='+cookieValue+'; expires='+expirationTime+'; path='+cookiePath; } return getCookie('landing_page') }
The GA4 tag
Next, add the variable as an event parameter value to each of your relevant GA4 event tags inside Google Tag Manager.
![](https://www.roelpeters.be/wp-content/uploads/2021/06/image-1-1024x560.png)
The GA4 configuration
Next, go to Google Analytics 4. In the menu, go to Custom Definitions > Create custom dimensions and do as follows.
![](https://www.roelpeters.be/wp-content/uploads/2021/06/image-2.png)
You can now link events and conversion to a particular landing page. Great success!
It looks like GA4 will now have a dedicated Landing Page dimension.
https://developers.google.com/analytics/devguides/reporting/data/v1/changelog
This was an excellent method to get a beloved dimension. Many thanks for putting it together!
Thanks, Mike!
Hi, I still cannot find the landing page dimension in the “explore” section, should I enable it somewhere?