This feature is part of an open beta and is subject to change.
These instructions are for administrators and editors who have activated user-provided data collection and want to start sending user-provided data from a website using gtag.js.
Before you begin
You must turn on user-provided data collection in Google Analytics.
Choose how to identify user-provided data
- In Admin, under Data collection and modification, click Data streams.
Note: The previous link opens to the last Analytics property you accessed. You can change the property using the property selector. You must be an Editor or above at the property level to configure your user-provided data settings.
- Select the desired web data stream.
- Under Google tag, click Configure tag settings > Allow user-provided data capabilities.
- Enable Allow user-provided data capabilities.
- Choose one or more ways to identify user-provided data:
Option Description Automatically detect user-provided data Google Analytics inspects your web pages for strings that match the pattern for an email address. Phone numbers and addresses are excluded from the option. We recommend supplementing the option with the following options. Specify CSS selectors or JavaScript variables Select the types of user-provided data you want to collect, such as email addresses or phone numbers. For each type of data, select how you want to identify the data on the page — either a CSS selector or global JavaScript variable. Learn more about this option
This method is more precise than automatically detecting user-provided data, but not as reliable as adding a code snippet to your website. If you frequently change your website code, in particular the formatting or CSS selectors on the collection page, you may want to consider adding a code snippet to your website.
Add a code snippet to your website Add JavaScript code to your web pages to collect email addresses, phone numbers, and/or names and addresses. Then, set the user_data parameter for each event on the page. Learn more about this option - Click Save.
Fields to set
The following table describes each field you can set. The key name shows how you must reference the field in your code. You must pass the data as a String type. When defining name and address, make sure to define each component as an individual variable (for example, first name, last name, and so on).
Note: If you want to send unhashed data and let Google normalize and hash the data, use the first key name for each data field. For example, email in the Email address data field below. If you want to send hashed data, use the key name that begins with sha256_.
Data Field | Key Name | Description |
---|---|---|
Email address | email |
User email. Example: ‘[email protected]’ |
sha256_email_address |
Hashed user email. Example: ‘a8af8341993604f29cd4e0e5a5a4b5d48c575436c38b28abbfd7d481f345d5db’ |
|
Phone number | phone_number |
User phone number. Must be in E.164 format, which means it must be 11 to 15 digits including a plus sign (+) prefix and country code with no dashes, parentheses, or spaces. Example: ‘+11231234567’ |
sha256_phone_number |
Hashed user phone number. Example: ‘e9d3eef677f9a3b19820f92696be53d646ac4cea500e5f8fd08b00bc6ac773b1’ |
|
First name | address.first_name |
User first name. Example: 'John' |
address.sha256_first_name |
Hashed user first name. Example: ‘96d9632f363564cc3032521409cf22a852f2032eec099ed5967c0d000cec607a’ |
|
Surname | address.last_name |
User last name. Example: 'Doe' |
address.sha256_last_name |
Hashed user last name. Example: ‘799ef92a11af918e3fb741df42934f3b568ed2d93ac1df74f1b8d41a27932a6f’ |
|
Street address | address.street |
User street address. Example: '123 New Rd' |
City | address.city |
User city name. Example: `Southampton’ |
Region | address.region |
User province, state, or region. Example: `Hampshire’ |
Postal code | address.postal_code |
User post code. Example: 'SO99 9XX' |
Country | address.country |
User country code. Example: 'UK'. Use 2-letter country codes, per the ISO 3166-1 alpha-2 standard. |