First-party data

‫[GA4] הוספת קטע קוד לאתר (gtag.js)

התכונה הזו היא חלק מגרסת בטא פתוחה וכפופה לשינויים.

ההוראות האלה מיועדות לאדמינים ולעורכים שמגדירים איסוף פרטים שהמשתמשים סיפקו, ורוצים להוסיף קטע קוד לאתר באמצעות gtag.js. קוד מעודכן באתר מאפשר למערכת Analytics לגשת לכתובות אימייל, מספרי טלפון ו/או שמות וכתובות כשהיא אוספת פרטים שהמשתמשים סיפקו.

סקירה כללית

כדי לעדכן את הקוד באתר, אתם צריכים להגדיר באמצעות הפונקציה gtag( )‎ את הערך של user_data בכל שדה של פרטים שהמשתמשים סיפקו בפקודה מסוג event,‏ config או set.

אם מעבירים את אותם נתונים בתוך שני סוגי פקודות או יותר (לדוגמה, event ו-config), הפקודה event תבטל את הפקודה config והפקודה config תבטל את הפקודה set. כאן אפשר לקבל מידע נוסף על קדימות הפרמטרים ב-Google Tag.

צריך לעדכן את הקוד בכל דף שבו נאספים פרטים שהמשתמשים סיפקו, כמו דף הרשמה, דף יצירת לידים, דף תשלום או דף דומה. כדי לוודא שהנתונים יישלחו ל-Analytics, אתם יכולים לשלוח את הנתונים יותר מפעם אחת במהלך סשן.

לפני שמתחילים

במסגרת ההנחיות האלה, אנחנו מניחים:

  • שיש לכם גישה לקוד המקור של האתר
  • שהפעלתם איסוף פרטים שהמשתמשים סיפקו ואפשרתם יכולות שקשורות לפרטים שהמשתמשים סיפקו

Hashing the data

You can send hashed or unhashed data from a website. If you send unhashed data, Google normalizes and hashes the data before the data reaches Google's servers. To ensure Analytics interprets the data correctly and to comply with the User-provided data policy, you must use the correct key name (in the next section).

To hash the data:

To normalize the data:

  • Remove leading or trailing whitespaces.
  • Convert the text to lowercase.
  • Format phone numbers according to the E.164 standard.

Defining the fields in your code

You must provide at least one of these fields:

  • Email (preferred).
  • Address (first name, last name, postal code, and country are required). You can optionally provide street address, city, and region as additional match keys.
  • A phone number can also be provided along with an email or full name and address.

Make sure the data is available when the Google tag fires. If the data is collected on a previous page, make sure it’s available in your code on the current page so you can configure the field.

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: ‘jdoe@example.com’

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.

הטמעת השדות בקוד

בכל דף שבו נאספים אוספים נתוני לקוחות, אתם צריכים להגדיר את הפרמטר user_data בכל שדה שאתם רוצים להגדיר.

דוגמה

בדוגמה הבאה משתנים משמשים לשמירת נתוני הלקוחות. חשוב לוודא ששמות המשתנים בקוד תואמים למאפיינים באתר. למשל, אם אתם מאחסנים כתובות אימייל במשתנה email_address, אתם צריכים לציין אותו בקטע הקוד במקום המשתנה הקיים (yourEmailVariable).

אתם יכולים גם להגדיר את שם השדה ברמת הקוד באמצעות מחרוזת או להשתמש בפונקציה במקום במשתנים.

‎// Implement

‎<script>
‎ ‎ gtag('set', 'user_data', {
‎ ‎ "email": yourEmailVariable, ***משנים את yourEmailVariable לשם המשתנה ב-JavaScript שבו מאוחסנים נתוני האימייל של המשתמש. חוזרים על הפעולה כדי להגדיר אחד-אחד את כל המשתנים האחרים שמפורטים בהמשך. בודקים שהערכים לא מגובבים.
‎ "phone_number": yourPhoneVariable,
‎ ‎ "address": {
‎ ‎ "first_name": yourFirstNameVariable,
‎ ‎ "last_name": yourLastNameVariable,
‎ ‎ "street": yourStreetAddressVariable,
‎ ‎ "city":yourCityVariable,
‎ ‎ "region": yourRegionVariable,
‎ ‎ "postal_code": yourPostalCodeVariable,
‎ ‎ "country": yourCountryVariable
‎ ‎ }
‎ ‎ });
‎ ‎ </script>‎

מספר הטלפון חייב להיות בפורמט E.164. כלומר סימן פלוס (+) ואחריו 11-15 ספרות, כולל קידומת המדינה, ללא מקפים, סוגריים או רווחים.

הסרת שדות ריקים

אם אתם לא אוספים שדות מסוימים מקוד הדוגמה הקודם, אתם צריכים להסיר את השדות לחלוטין מהקוד – לא להשאיר אותם ריקים. לדוגמה, למטה אפשר לראות איך ייראה קוד באתר שנאספים בו רק מספרי טלפון וכתובות אימייל:

‎// Implement
‎ ‎ <script>
‎ ‎ gtag('set', 'user_data', {
‎ ‎ "email": {{ yourEmailVariable }},
‎ ‎ "phone_number": {{ yourPhoneVariable }}
‎ ‎ });
‎ ‎ </script>‎

הוספת כמה ערכים

אפשר להוסיף לקוד משתנים לכמה ערכים מאותו סוג (עד 3 מספרי טלפון וכתובות אימייל ו-2 כתובות) באמצעות מערך. כך ייאספו כל הערכים שהמשתמש סיפק בכל שדה, ויעלה הסיכוי שאחד מהם יתאים לנתונים שלכם.

‎<script>
‎ ‎ gtag('set', 'user_data', {
‎ ‎ "email": [yourEmailVariable1, yourEmailVariable2],
‎ ‎ "phone_number": [yourPhoneVariable1, yourPhoneVariable2],
‎ ‎ "address": [
‎ ‎ {‎
‎  first_name: yourFirstNameVariable,‎
‎  last_name: yourLastNameVariable,‎
‎  street: yourStreetAddressVariable,‎
‎  city: yourCityVariable,‎
‎  region: yourRegionVariable,‎
‎  postal_code: yourPostalCodeVariable
‎},
‎ {‎
‎  first_name: yourFirstNameVariable,‎
‎  last_name: yourLastNameVariable,‎
‎  street: yourStreetAddressVariable,‎
‎  city: yourCityVariable2,‎
‎  region: yourRegionVariable2,‎
‎  postal_code: yourPostalCodeVariable2
‎}
‎ ]
‎ ‎ });
‎ ‎ </script>‎

האם המידע הועיל?

איך נוכל לשפר את המאמר?
חיפוש
ניקוי החיפוש
סגירת החיפוש
אפליקציות Google
התפריט הראשי
7706898234090337071
true
חיפוש במרכז העזרה
false
true
true
true
true
true
69256
false
false
false
false