[GA4] Как указать селекторы CSS или переменные JavaScript (gtag.js)

This feature is part of an open beta. Keep in mind that the feature is subject to change.

Эти инструкции предназначены для администраторов и пользователей с правами на редактирование, которые настраивают сбор данных, предоставленных пользователями, и хотят узнать, как идентифицировать такие данные с помощью селекторов CSS или переменных JavaScript на странице "Использовать данные, предоставленные пользователями".

Обзор

Вам необходимо обновить код на каждой странице, где вы собираете данные, предоставленные пользователями, например на странице регистрации, странице для привлечения потенциальных клиентов, странице оформления покупки и т. д. Чтобы данные точно были переданы в Аналитику, можете отправлять их несколько раз за сеанс.

Подготовка

В этой инструкции подразумевается, что у вас:

  • включен сбор данных, предоставленных пользователями, и настроены необходимые разрешения;
  • есть роль администратора в ресурсе Google Аналитики.

Identify CSS selectors for user-provided data fields

To identify the CSS selectors to input into the fields, complete these steps for each field. If you already have unhashed variables in your code, you can select those instead of creating new CSS variables.

Note: If you’re using JavaScript variables, it’s likely easiest to ask your developer which variables should be added to these fields. If you’re using CSS Selectors, you can follow the steps below.

  1. Open a Google Chrome browser window.
  2. Go to your website, but keep Google Tag Manager open.
  3. Identify the customer data you want to send to Google Analytics. For example, if you want to send an email address, identify where the email address is present on the page.
  4. Right click the field and select Inspect. For example, if you are trying to capture an email address, make sure you are right clicking the email address.
  5. On the Chrome Developer Tools page, you will see a portion of the code highlighted. This code is the page element where you need to extract CSS Selectors for the customer data.
  6. Hover your mouse over the highlighted code and right-click it.
  7. Scroll down to "Copy", then select Copy Selector.
  8. Paste the copied text in the corresponding field in Google Analytics or Tag Manager.
    • The copied text should look something like the following:

      tsf > div:nth-child(2) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > custEmail

Next steps

Validate that user-provided data collection is set up correctly. Show me how.

Эта информация оказалась полезной?

Как можно улучшить эту статью?
Поиск
Очистить поле поиска
Закрыть поиск
Главное меню
8088741932092923356
true
Поиск по Справочному центру
true
true
true
true
true
69256
false
false