Track pageviews

The global tracking snippet automatically sends a pageview hit to Google Analytics, unless you disable pageview tracking. However, you may want to send pageview hits to Google Analytics on an ad-hoc basis.


Use the config command to send a pageview:

gtag('config', 'GA_TRACKING_ID', {<pageview_parameters>});

where GA_TRACKING_ID is your Google Analytics tracking ID and <pageview_parameters> is one or more parameter-value pairs. Separate each pair by a comma. For example, this code sends a pageview to Google Analytics with a page title of 'homepage' and a page path of '/home'.

gtag('config', 'GA_TRACKING_ID', {
  'page_title' : 'homepage',
  'page_path': '/home'

Pageview parameters

The following table lists pageview-related parameters.

Parameter name Value type Required Description
page_title string No The page's title.
page_location string No The page's URL.
page_path string No The path portion of location. This value must start with a slash (/) character.

Multiple properties

To send a pageview to multiple Google Analytics properties, specify a config for each property.

gtag ('config', 'GA_TRACKING_ID_1');
gtag ('config', 'GA_TRACKING_ID_2');