Reporting on GA4 Landing Pages in Looker Studio

The GA4 data source in Looker Studio doesn’t include a Landing Pages dimension. A YouTube commenter recently asked me if I knew a solution to this problem. I didn’t, but their question led me to learn some important concepts related to user properties and custom dimensions in GA4. I also got to play with custom JavaScript tags in GTM, the dataLayer and a blend in Looker Studio. Most importantly, I was able to figure out a solution that works well, though with a few limitations. The end result of my experimentation was this glorious report:

This image has an empty alt attribute; its file name is image-6-1024x714.png

The steps to create a report like this are detailed below, as well as sample code for persisting a user’s landing page in a cookie. I also recorded a video describing the process.

the landing page report in ga4

The Landing page report can be found under Reports > Engagement in GA4. If it’s not there in your GA4 property, you can add it by clicking on the Library icon, finding the report and adding it to your navigation (Google help on how to do this). The landing page report shows sessions, users, engagement, conversions and revenue tied to the page on which a user lands at the start of a session. 

The GA4 landing page dimension is not available in Looker Studio

It’s a bit mysterious as to why Google doesn’t make this important dimension available in Looker Studio, but as of this writing, they don’t.

GA4 Doesn’t Support Session-Scoped Custom Dimensions

Before I get to the solution that worked, let me share what didn’t work. Figuring out why it failed helped me understand a key principle related to custom dimensions and pointed me in the right direction. The first thing I tried was to get the page_location parameter from the session_start event and store it in a custom dimension. To do this, I had to create a new landing event in GA4 that inherited and renamed the page_location parameter from session_start. This kind of worked, but did not produce the dimension I wanted.

dimension scopes

Custom dimensions can have two scopes, Event and User. Because my custom dimension was tied to an event parameter, my only option was to set it to Event scope. With an event-scoped dimension, you can only see event-scoped metrics. In my case, I could report on the metric Event count with my dimension, which would tell me how many sessions started on a given page, but I couldn’t report on metrics like Users, Engagement rate or Conversions. Not very useful.

The GA4 Landing page dimension is session-scoped. This means you can use it to report on metrics aggregated by session. Unfortunately, GA4 doesn’t support session-scoped custom dimensions.

Once I figured all of this out, I gave up on being able to recreate the Landing page dimension exactly, but I did wonder if I could create a user-scoped dimension. It turned out I could, and the steps to do so are outlined below.

Google help page on the landing page report

creating a user-scoped dimension for landing page

 

1. create a custom html tag in google tag manager

If you’ve been doing any customization in GA4, you know that Google Tag Manager (GTM) is an essential part of your toolkit. Since we can’t create session-scoped dimensions in GA4, we’ll use GTM to persist a user property that stores the page path on which the user first arrived at a site.

The following code persists the user’s landing page path between visits. To implement it, copy the code into a new Custom HTML tag in GTM. Set the trigger to Page View > All Pages.

There are two functions in the code. The first is a utility function that gets a user’s cookie based on the cookie name. The second is a self-executing function that stores a user’s landing page path in a cookie the first time it loads and pushes the path value to the dataLayer. On subsequent loads, it gets the stored page path value from the cookie and pushes that to the dataLayer.

If you are wondering why we are getting the user’s page path instead of the full landing page URL, the reason is because GA4 User Properties can’t be longer than 36 characters. Because of that, we need to economize on the number of characters we are pushing to the property.

				
					<script>
// this function returns a cookie based on the cookie's name
function gtm_getCookie(name) {
 var cookies = decodeURIComponent(document.cookie);
 var cookiesArray = cookies.split(';');
 var cookie = cookiesArray.find(function (item) {
   return name == item.trim().substring(0, name.length);
 });
 return cookie;
}

(function() {
 var urlCookie = gtm_getCookie("lp_path");
 // if no url cookie exists, create it and push url to datalayer
 if (!urlCookie) {
   var cookieExpiry = new Date();
   // Set expiry time of one year
   cookieExpiry.setFullYear(cookieExpiry.getFullYear() +1);
   var expires = "expires=" + cookieExpiry.toUTCString();
   // user parameters are <= 36 characters, so we're not pushing the full URL
   dataLayer.push({"lp_path" : {{Page Path}}});
   document.cookie = "lp_path" + "=" + {{Page Path}} + ";" + expires + ";path=/";
 } else {
    // if cookie exists, get the url from it and push to dataLayer
	  var pathFromCookie = urlCookie.trim().slice(8) || null;
     dataLayer.push({"lp_path" : pathFromCookie});
 }
})();
</script>

				
			

2. create a custom variable in gtm

The Data Layer Variable type in GTM gets a value from the dataLayer and makes it available to other tags. The script above pushes a ‘lp_path’ variable to the dataLayer. This turns it into a GTM variable.

GTM lp_path dataLayer variable

3. add a user property to the ga4 configuration tag

Modify your GA4 configuration tag in Google Tag Manager to include the following user property. Set the value of the property to the variable you just created. Note that double curly braces tell GTM to insert a dynamic GTM variable value.

I named the property ‘first_user_landing_page’ because GA4 prefixes various user-scoped dimensions with ‘First user’. For example, the ‘First user default channel grouping’ dimension indicates the channel a user came from the first time they visited a site.

first_user_landing_page user property

4. update the configuration tag trigger

At this point, you have everything you need in GTM, but there’s one problem: assuming your GA4 configuration tag is also triggered on Page View, the path variable you created won’t exist when the configuration tag fires. You can fix this by changing your configuration tag to fire on the DOM Ready trigger. If you do this, keep in mind that other GA4 tags inherit parameters set in the configuration tag, so you should update their triggers as well. Another way to accomplish the same result would be to configure tag sequencing to fire the Custom HTML tag before the configuration tag.

At this point you are done with the GTM portion of this process. Test your new tag, variable and configuration tag change in GTM preview mode and publish your changes if everything looks good.

5. add a ‘first user landing page’ custom dimension in ga4

In GA4, go to Admin > Custom definitions and add the following dimension.

Custom dimension dialogue box in GA4

6. refresh your ga4 connection in looker studio

You’ll need to wait at least a day for data to populate in GA4 before this step.

When ready, refresh your GA4 data source.

7. create a lookup table in a google sheet

I mentioned above that GA4 limits user properties to 36 characters. This is pretty annoying for our purposes, since page paths can often be longer than that. I fixed this in Looker Studio by creating a lookup table in a Google Sheet that cross-references truncated page paths with complete page paths. Below is an example of what this table looks like. I created the lookup column on the left with the Google Sheets LEFT formula, e.g. =LEFT(B2,26)

Screenshot of a Google Sheet with landing page lookups.

You’ll then need to create a new data source in Looker Studio to connect to your Sheet.

8. create a blend in looker studio to join to your lookups

We’re so close! The last step is to create a blend in Looker Studio from your GA4 data source and the lookup table to get the full LP path in your report. Below is how I have my blend set up, but feel free to pull in other metrics from your GA4 data source.

Also notice that I added a filter to my GA4 data source – the filter excludes null values from the blend. This is not absolutely necessary, but you will likely get some instances where your configuration tag fires and the custom HTML tag you created has not populated the path value.

One caution: make sure not to have any duplicate rows in the lookup sheet. Duplicate rows on the right side of your join will result in duplicate rows in the joined data, which will inflate your metrics.

image 4

Voilá, that’s it! You now have a blend you can use to report on First user landing page in Looker Studio!

beware of cardinality

Plus a few other gotchas.

Google's warning: "Creating a custom dimension with a high number of unique values may negatively impact your reports."

Google recommends that you avoid creating custom dimensions with “high-cardinality”. What this means specifically is that dimensions with more than 500 unique values may affect reporting performance, and will result in some of your landing pages being aggregated into an “other” row in reporting. So, if you have a lot more than 500 pages on your site that users are likely to land on, the technique I have described here may be of limited value.

A few more things to keep in mind:

  • GTM automatically applies consent settings to Google tags, but not custom HTML tags, so make sure you configure it appropriately according to your consent policy when you create the tag.
  • This process relies on a 1st-party cookie. As such, it will not persist a user’s landing page if the user is blocking 1st-party cookies.
  • The approach I described relies on a lookup existing in the lookup table – if your page paths change a lot, you may want to just report on the first 36 characters and call it good.
  • If your site requires URL parameters to identify unique pages, you’ll need to use the Page URL GTM variable instead of Page Path. You can remove the protocol and domain in the JavaScript function, but this still might not be enough to get below 36 characters.

If you’d like help with this or anything else to do with GA4 or Looker Studio, check out our marketing data analysis services.

Read more GA4 resources and tutorials.

Share This Post

Share This Post

master GA4

with personalized training

A training program like no other. Work with expert marketers for 1:1 training to maximize learning & impact.

have you registered?

Our next free digital marketing seminar is coming soon!

[MEC id="946"]