How to tag for both Web and App + Web properties

This article describes how to instrument a website/web-app with tags to populate Web and App + Web properties at the same time. More advanced functionality (e.g. ecommerce) is covered in companion articles.

Use the following buttons to pick the library you are currently using:

Set up the basic page tag

To populate both your Web and App + Web properties, you’ll need to either add a new tag or modify your existing page tag.

Generate a virtual pageview

If you generate virtual pageviews in analytics.js, for example:

ga('set', 'page', '/my-virtualpage-path');
ga('send', 'pageview');

you can do the same thing in gtag.js as follows:

gtag('config', 'G-XXXXXXXXXX', {
  'page_path': '/my-virtualpage-path'

Disable data collection

If your site's privacy policy provides an option for the user to opt-out of Google Analytics, you’ll need to instrument the opt-out for both your Web and App + Web properties.

IP anonymization

In App + Web properties, IP addresses are automatically anonymized. No further action is necessary to anonymize IP addresses for App + Web properties.