Google Analytics collects information about your web pages and app screens by adding information about them to events. You can use this information to populate dimensions and metrics to see which pages and screens your users interact with.
While Google collects data about pages and screens automatically, you can also manually collect information about your pages and screens.
Measure pages and screens automatically
Use the following drop-downs to learn how Google Analytics measures pages and screens:
Global site tag (Websites)
The global site tag snippet includes a config
command that collects pageview data:
gtag('config', 'MEASUREMENT_ID');
You can add parameters to the config
command after the measurement ID to capture more information about the pageview. Use the following structure to capture parameters:
gtag('config', 'MEASUREMENT_ID', <parameters>);
For example, you can include the following parameters to capture the page URL and title:
gtag('config', 'MEASUREMENT_ID', {
page_title: 'My Profile',
page_location: 'https://example.com/me' // Include the full URL
});
Google Tag Manager (Websites)
Google Analytics for Firebase (Mobile apps)
Disable pageviews and screenviews
Use the following drop-downs to see information about how to disable pageviews and screenviews:
Global site tag (Websites)
To disable a pageview, set the send_page_view
parameter to "false" as follows:
gtag('config', 'MEASUREMENT_ID', {
send_page_view: false
});
The parameter does not persist across pages; you must repeat the setting on every web page to disable automatic pageviews.
Google Tag Manager (Websites)
Google Analytics for Firebase (Mobile apps)
Measure pages and screens manually
Use the following drop-downs to see information about how to send pages and screens manually:
Global site tag (Websites)
To send your own pageviews, add the following event:
gtag('event', 'page_view', {
page_title: 'My Profile',
page_location: 'https://example.com/me', // Include the full URL
send_to: '<MEASUREMENT_ID>'
});
Google uses default values for any parameters you don't set. Only set the send_to
parameter when you want to send the page_view
event to a different property than the one configured in the default snippet.
Google Tag Manager (Websites)
Google Analytics for Firebase (Mobile apps)
Measure virtual pageviews
If your site loads page content dynamically and updates the document's URL, you might want to send additional pageviews to measure these virtual pageviews. To measure virtual pageviews, do one of the following:
- Rely on Enhanced measurement, which is enabled by default and sends a pageview when the browser history state changes.
- Manually measure virtual pageviews by relying on the default snippet behavior or the
page_view
event to send a pageview.
If you manually send page_view
events, make sure Enhanced measurement is configured correctly to avoid double counting pageviews on history state changes. Typically, this means disabling Page changes based on browser history events under the advanced settings of the Page views section.
- When a pageview is sent to Analytics, the default page parameter values are used, unless modified. This means you do not need to modify
page_title
orpage_location
parameters if updates towindow.location
(e.g. via the History API) anddocument.title
are made prior to the event being sent. - If your app relies on a library to handle page updates it's recommended that you review the behavior to confirm the library sets
window.location
anddocument.title
as expected. Alternatively, you can always explicitly set page parameters when sending apage_view
event to ensure accuracy and clarity.