First-party data

הגדרת קטע הקוד (Tag Manager)

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

ההוראות האלה מיועדות לאדמינים ולעורכים שרוצים להגדיר באמצעות Google Tag Manager את קטע הקוד לאיסוף פרטים שהמשתמשים סיפקו באתר שלהם.

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

סקירה כללית

כדי להגדיר את קטע הקוד באמצעות Google Tag Manager, מבצעים את השלבים הבאים:

  1. מזהים ומגדירים בקוד האתר שדות עם פרטים שהמשתמשים סיפקו
  2. מעבירים אל Google Analytics כל שדה עם פרטים שהמשתמשים סיפקו, במשתנה JavaScript מותאם אישית

הערה: הנתונים שאתם שולחים ל-Google Analytics יכולים להיות מגובבים (hashed) או לא מגובבים. כשאתם שולחים נתונים לא מגובבים, Google מבצעת גיבוב של הנתונים בשבילכם לפני שהיא מאחסנת אותם בשרתים שלה. אתם יכולים גם לבצע גיבוב של הנתונים בצד שלכם לפני שאתם שולחים אותם ל-Google.

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

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

  • שיש לכם גישה לקוד המקור של האתר
  • שהפעלתם איסוף פרטים שהמשתמשים סיפקו ואפשרתם יכולות שקשורות לפרטים שהמשתמשים סיפקו
  • שהגדרתם תג מעקב אירועים מסוג Google Analytics: Google Analytics במאגר התגים של Google Tag Manager
  • שיש לכם תפקיד אדמין בנכס ב-Google 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.

איך מעדכנים את תג מעקב האירועים באמצעות משתנה JavaScript מותאם אישית

לפני שאתם מעדכנים את מאגר התגים של Tag Manager, כדאי שתקראו איך לעדכן את קוד ה-JavaScript בהתאמה אישית שאתם מוסיפים למאגר.

  1. נכנסים לחשבון Google Tag Manager.
  2. בכרטיסייה Workspace (סביבת עבודה), לוחצים על Tags (תגים) בצד שמאל.
  3. פותחים את התג Google Analytics: Google Analytics Event במקום שבו אוספים נתוני לקוחות. מוודאים שבתג מעקב האירועים מוגדר מזהה המדידה של המקור לנתוני האתר שבו נאספים נתוני המשתמשים.
  4. מרחיבים את הקטע Event Parameters (פרמטרים של אירועים) ולוחצים על Add parameter (הוספת פרמטר).
  5. מזינים user_data בשדה “Event Parameter” (פרמטר של אירוע). 
  6. בשדה "Value" (ערך), בוחרים או יוצרים משתנה מסוג User-Provided Data (פרטים שהמשתמשים סיפקו).
  7. אם יוצרים משתנה חדש, בוחרים באפשרות Code (קוד) במשתנה User-Provided Data (פרטים שהמשתמשים סיפקו).
  1. בתפריט הנפתח Data Source (מקור נתונים), לוחצים על New Variable...‎ (משתנה חדש).
  2. לוחצים על Variable Configuration (תצורת משתנה) > Custom JavaScript ‏(JavaScript בהתאמה אישית).
  3. בראש הדף מזינים שם למשתנה ה-JavaScript המותאם אישית.
  4. בתיבת הטקסט Custom JavaScript ‏(JavaScript בהתאמה אישית), מזינים את קטע הקוד. כך עושים את זה.
  5. שומרים את המשתנים החדשים ואז שומרים את תג מעקב האירועים.
  6. בפינה הימנית העליונה, לוחצים על Submit (שליחה) כדי לפרסם את השינויים.

איך יוצרים את קטע הקוד לאיסוף פרטים שהמשתמשים סיפקו

אפשר להשתמש בקוד הבא כשמגדירים את משתנה ה-JavaScript המותאם אישית בשלב 10:

function () {

return {

‎"email":‎ yourEmailVariable , // מחליפים את yourEmailVariable בשם המשתנה שמתעד את כתובת האימייל של המשתמש

‎"phone_number":‎ yourPhoneVariable , // מחליפים בהתאם גם את yourPhoneVariable ואת שמות המשתנים שבהמשך

"address": {

"first_name"‏: yourFirstNameVariable ,

"last_name"‏: yourLastNameVariable ,

"street": yourStreetAddressVariable ,

"city": yourCityVariable ,

"region": yourRegionVariable ,

"postal_code": yourPostalCodeVariable ,

"country": yourCountryVariable

}

}

}

בדוגמת הקוד, מחליפים את משתני הפלייסהולדר (למשל, yourEmailVariable) של כל סוג של נתוני משתמש בשם המשתנה הגלובלי של JavaScript שמכיל את אותו חלק מהנתונים. אם האתר שלכם לא אוסף נתונים לגבי אחד מהשדות שצוינו, אתם צריכים להסיר את השדה מהקוד לגמרי – לא להשאיר אותו ריק.

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

// Implement
<script>
gtag('set', 'user_data', {‎

‎"sha256_email_address": yourNormalizedandHashedEmailVariable
‎"sha256_phone_number": yourNormalizedandHashedPhoneVariable,‎
‎"address": {‎
‎"address.sha256_first_name": yourNormalizedandHashedFirstNameVariable,‎
‎"address.sha256_last_name": yourNormalizedandHashedLastNameVariable,‎
‎"city": yourCityVariable,‎
‎"region": yourRegionVariable,‎
‎"postal_code": yourPostalCodeVariable,‎
‎"country": yourCountryVariable
‎}‎
‎});‎
‎</script>‎

אם אתם רוצים לספק ערכים מגובבים של נתוני משתמשים, אתם יכולים להשתמש בקטע הקוד הבא לדוגמה:

async function processUserData() {‎
const userData = {‎

‎'sha256_email_address': await hashEmail(email.trim()),‎
‎'sha256_phone_number': await hashPhoneNumber(phoneNumber),‎
‎'address': {‎
‎'address.sha256_first_name': await hashName(firstName),‎
‎'address.sha256_last_name': await hashName(lastName),‎
‎'city': city,‎
‎'region': region,‎
‎'postal_code': postalCode,‎
‎'country': country,‎
‎},‎
‎};‎
return userData;‎

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

Next steps

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

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

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