First-party data

[إحصاءات Google‏ 4] إضافة مقتطف رمز إلى موقعك الإلكتروني (gtag.js)

هذه الميزة جزء من إصدار تجريبي مفتوح وعرضة للتغيير.

هذه التعليمات مخصَّصة للمشرفين والمحرِّرين الذين يُعِدّون ميزة جمع البيانات المقدَّمة من المستخدِم ويريدون التعرّف على كيفية إضافة مقتطف رمز إلى مواقعهم الإلكترونية باستخدام gtag.js. عند تعديل الرمز على موقعك الإلكتروني، يساعد ذلك على التأكّد من توفّر عناوين البريد الإلكتروني و/أو أرقام الهواتف و/أو الأسماء والعناوين على الصفحة عندما تجمع "إحصاءات Google" البيانات المقدَّمة من المستخدِم.

نظرة عامة

لتعديل رمز موقعك الإلكتروني، عليك إعداد قيمة user_data مع كل حقل بيانات مقدَّمة من المستخدِم ضِمن أمر event أو config أو set باستخدام الدالة gtag( )‎.

في حال إرسال البيانات نفسها في نوعَين أو أكثر من أنواع الأوامر (مثل event وconfig)، سيتجاوز الأمر event الأمر config، كما أنّ الأمر config سيتجاوز الأمر set. مزيد من المعلومات عن أولوية مَعلمات علامة Google

عليك تعديل الرمز في أيّ صفحات تجمع فيها البيانات المقدَّمة من المستخدِم، مثل صفحة الاشتراك أو صفحة جذب العملاء المحتمَلين أو صفحة الدفع أو ما شابه ذلك. يمكنك إرسال البيانات أكثر من مرّة خلال الجلسة لضمان إرسال البيانات إلى "إحصاءات Google".

قبل البدء

تفترض هذه التعليمات أنّك تستوفي الشرطَين التاليَين:

  • لديك الإذن بالوصول إلى رمز المصدر الخاص بموقعك الإلكتروني
  • تم تفعيل ميزة جمع البيانات المقدَّمة من المستخدِم وتم السماح بإمكانيات البيانات المقدَّمة من المستخدِم

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, ***Change yourEmailVariable to the actual Javascript variable name where you are storing the user’s email data. نفِّذ الإجراء نفسه مع المتغيّرات الأخرى التي ترد في ما يلي. وتأكّد من أنّ القيم لم تتمّ تجزئتها.
"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 أرقام هواتف وعناوين بريد إلكتروني وعنوانَين) باستخدام مصفوفة. وفي حال سجَّلت أكثر من قيمة واحدة، سيؤدي تقديم ذلك إلى زيادة احتمال حدوث مطابقة.

<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>

هل كان ذلك مفيدًا؟

كيف يمكننا تحسينها؟
false
بحث
محو البحث
إغلاق البحث
تطبيقات Google
القائمة الرئيسية
12907378428957778855
true
مركز مساعدة البحث
false
true
true
true
true
true
69256
false
false
false
false