GA4
Advanced Measurement

enhanced measurement

SHOULD YOU MANUALLY SET THE PAGE_VIEW EVENT IN GOOGLE ANALYTICS 4 USING GTM?

Page View Event - Single Page App

https://ken-williams.com/guide/installation/should-you-manually-set-the-page_view-event-in-an-app-web-property-using-gtm/

SHOULD YOU MANUALLY SET THE PAGE_VIEW EVENT IN GOOGLE ANALYTICS 4 USING GTM?

by KenPosted onMay 10, 2020

NOTE: If you have not already set up Google Analytics 4 within Google Analytics, check out previous post.

Let me start this post by stating that Google, Krista Seiden, and Simo Ahava have all done a thorough job of documenting how you should set up the App + Web Configuration Tag. In some cases, you can just check the box that says “Send a page view event when this configuration loads” in your GTM tag settings and you’re done.

However, there are many reasons why you might opt to set up a “page_view” event that is separate from your configuration tag (see below). The purpose of this post is to explain why you might need to do this, and share some best practices to make sure you’ve done it correctly.

img

Who Should Avoid the Checkbox?

It’s really all about timing, and there are two things to consider:

  1. When should my pageview event fire?
  2. What parameters and user properties should be set with my pageview event?
  3.  

(question1 == “any time a page loads” && question2 ==“none”) ? Use the checkbox : Keep reading;

Consideration #1: When Should My Pageview Event Fire?

To keep your Google Analytics 4 data similar to the traditional Google Analytics data you are familiar with, I recommend firing a pageview according to the same logic that we previously applied to Universal Analytics: whenever the user views a new page.

So, do not use the checkbox if your site is a single page app. With Single Page Apps (SPAs), how we define a “page”, however, can get a little tricky. On a traditional website the user is presented with a series of pages, and each page loads sequentially as the user navigates the site. However, traditional websites are slow, and many developers prefer to dynamically modify the content on a single page rather than send the user across multiple pages as they navigate. This is why the web is rapidly moving toward SPAs.

In 2020, most of my clients are using SPA’s somewhere. If you have a checkout flow, there’s probably a 90% chance that it was built with a SPA. Since a single page app does not load an entire page when the user navigates through content, you will not see your App + Web Configuration tag and pageview fire either. So what’s the solution?

Solution #1: Fire a Pageview Event to the Data Layer

Google Tag Manager should not be used as a way to get around your development team. The absolute best practice here is to collaborate with your dev team to have them fire pageview events to your data layer, like so:

dataLayer.push({'event': 'page_view'});

You can then create a trigger using the “Custom Event” type, like so:

img

Now, if your dev team is lost at sea, Google Tag Manager does offer alternate approaches to identify when the user navigates between pages in a Single Page App. If you absolutely must use one of these, check out the history API and with polling until an element exists.

Before you run off and start creating tags in GTM, review consideration #2 as well.

Consideration #2: What Parameters and User Properties Should Be Set with My Pageview Event?

I do a lot of planning before I create anything in GTM. The reason is because you need to be very thoughtful about what business questions can be answered by Google Analytics data and how that data will be visualized. Once you have that plan, you need to reverse engineer it by creating the combinations of events and parameters that are necessary to power your visualizations.

Maybe I’ll discuss more about that in a later post, but for now just be aware that you need to be thoughtful about what attributes should be set with your pageview. Typically these attributes will fall into two categories: those that describe the event (like “page title”), and those that describe the user (like “authentication status”).

Validate that your pageview will not fire until after your event parameters and user properties are available. This can be simple in many cases, but it can be difficult if you have an asynchronous service that is supplying this data. This is common when you are pulling information from your CRM for authenticated users, and it may cause you to leverage promises or get creative.

Manually Setting Up a Pageview Event

If you’re still reading I’m going to assume it’s because the checkbox will not apply to you (probably because of one of the reasons listed above). So, you’re going to need to create a new “Google Analytics: App + Web Event Tag” to pass your pageview to GA4F. Here’s how to do it:

  1. First of all, you’re going to need that configuration tag. Just make sure that the “Send a page view event…” checkbox is unchecked (obviously).
  2. Create a new tag, and select “Google Analytics: App + Web Event Tag”
  3. Make sure your event name is “page_view”, because this is the Recommended Event that unlocks some additional features in the UI (<a href='https://support.google.com/analytics/answer/9267735'>although it’s not documented). Avoid “pageview”, or “pageView” or anything else.
  4. If you’re setting a User ID for your authenticated users, you’ll set this as a Field. If you would like to learn more about the User ID and why you should use it, read <a href='https://ken-williams.com/guide/installation/properly-setting-the-user-id-to-track-activity-across-web-and-app-with-google-analytics-for-firebase-app-web/'>THIS post.
  5. Finally, under “Advanced Settings” > “Additional Tag Metadata” there’s an option to set the tag name as a parameter. I always recommend that you should use this for 2 reasons: 1) if you see any strange data in reports this will make it easy to determine which GTM tag is responsible, and 2) because I asked the engineering team for this feature after the GA Summit in 2017 and so I feel a little responsible for it.
  6.  

Add your trigger to this tag according to the notes we discussed in consideration #1 above, and you’re ready to go.

 

 

 


 

https://support.google.com/analytics/answer/9216061

[GA4] Enhanced measurement

 

You’re required to ensure that no personally-identifiable information is collected.

Understanding PII in Google

Understanding PII in Google’s contracts and policies

https://support.google.com/analytics/answer/7686480

Many contracts, terms of service, and policies for Google’s advertising and measurement products refer to “Personally Identifiable Information” (PII). This is a different categorization of data from what the EU General Data Protection Regulation (GDPR) refers to as “personal data”.

Please note that data excluded from Google’s interpretation of PII may still be considered personal data under the GDPR, or personal information under the California Consumer Privacy Act (CCPA), and may therefore be subject to these laws.

This article explains how Google will interpret the term PII in the event PII isn’t defined in your existing contract or the applicable product’s terms of service or policies. This is to minimize confusion among customers and distinguish PII from concepts of personal data or personal information under the GDPR, CCPA and other privacy legislation.

What Google considers PII

Google interprets PII as information that could be used on its own to directly identify, contact, or precisely locate an individual. This includes:

  • email addresses
  • mailing addresses
  • phone numbers
  • precise locations (such as GPS coordinates – but see the note below)
  • full names or usernames

For example, if you’re a publisher whose contract prohibits you from passing PII to Google, the URLs of pages on your website that display ads by Google must not include email addresses, because those URLs would be passed to Google in any ad request. Google has long interpreted its PII prohibition in this way.

Note: Certain product’s help centers and policies set out the limited means by which certain forms of PII may be sent to Google. For avoidance of doubt, this article does not amend such provisions. So, for example, certain products allow approximate location data to be sent to Google, provided the requirements of the applicable policies are met.

Google interprets PII to exclude, for example:

  • pseudonymous cookie IDs
  • pseudonymous advertising IDs
  • IP addresses
  • other pseudonymous end user identifiers

For instance, if an IP address is sent with an ad request (which will be the case with almost any ad request as a consequence of internet protocols), that transmission will not breach any prohibition on sending PII to Google.

Note that data excluded from Google’s interpretation of PII may still be considered personal data or personal information under the GDPR, CCPA, and other privacy legislation. This article doesn’t affect any contract provisions or policies relating to personal data or personal information under those laws.

 

 

Enhanced measurement events are only collected for websites (web data streams) and they don’t count against the limit of 500 distinctly named events.

Enhanced measurement lets you measure interactions with your content by enabling options (events) in the Google Analytics interface. No code changes are required. When you enable these options for a web stream, your Google Analytics tag starts sending events right away.

Before turning on the enhanced measurement feature, be sure you understand each option and what data will be collected. You can also turn off specific measurement options.

The following table explains when events are triggered, and which parameters are collected for each event.

You’re required to ensure that no personally-identifiable information is collected.

Measurement option / event Triggered… parameters
Page viewspage_view each time the page loads or the browser history state is changed by the active site This event is collected automatically. You cannot turn off collection. An advanced setting on this option controls whether the event is sent based on browser-history events. This measurement option listens for pushState, popState, and replaceState. page_location (page URL), page_referrer (previous page URL)
Scrollsscroll the first time a user reaches the bottom of each page (i.e., when a 90% vertical depth becomes visible) No parameters are collected
Outbound clicksclick each time a user clicks a link that leads away from the current domain link_classes, link_domain, link_id, link_url, outbound (boolean)
Site searchview_search_results each time a user performs a site search, indicated by the presence of a URL query parameter By default, the event is triggered based on the presence of one of the following 5 parameters in the URL:qssearchquerykeywordYou can optionally configure this option to look for search terms in other parameters. search_term, optionally ‘q_’ (where matches an additional query parameter you specify to be collected under advanced settings)
Video engagementvideo_startvideo_progressvideo_complete For embedded YouTube videos that have JS API support enabled, the following events are triggered:video_start when the video starts playingvideo_progress when the video progresses past 10%, 25%, 50%, and 75% duration timevideo_complete when the video ends video_current_time, video_duration, video_percent, video_provider, video_title, video_url, visible (boolean)
File downloadsfile_download when a user clicks a link leading to a file (with a common file extension) of the following types:documenttextexecutablepresentationcompressed filevideoaudioFile extensions that match the following regex will trigger the event:pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma file_extension, file_name, link_classes, link_domain, link_id, link_text, link_url

Enable or disable enhanced measurement events

  1. Sign in to Google Analytics..
  2. Click Admin, and navigate to the property you want to edit.
  3. In the PROPERTY column, click Data Streams > Web.
  4. Under ENHANCED MEASUREMENT, turn on the switch to enable all options.
    Click Settings to edit individual options later if necessary.

 

Scroll to Top