קל לארגן דפים בעזרת אוספים אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בוחרים את הפלטפורמה:
פרוטוקול Measurement Protocol של Google Analytics לא מחזיר קודי שגיאה מסוג HTTP, גם אם האירוע מוגדר בצורה שגויה או שחסרים בו פרמטרים נדרשים. כדי לוודא שהאירועים תקינים, כדאי לבדוק אותם מול שרת האימות של Measurement Protocol לפני שתפרסו אותם בסביבת הייצור. אחרי שתבדקו שהאירועים שלכם מובנים בצורה נכונה, עליכם לבדוק את ההטמעה כדי לוודא שאתם משתמשים במפתחות הנכונים.
אפשר לבצע קריאה ישירה לשרת האימות או להשתמש בכלי ליצירת אירועים ב-Google Analytics. הכלי ליצירת אירועים ב-Google Analytics מאפשר ליצור אירועים באופן אינטראקטיבי, והוא משתמש בשרת האימות של Measurement Protocol כדי לאמת אותם.
במדריך הזה נסביר איך לשלוח אירועים ל-Measurement Protocol בשביל שרת האימות של Google Analytics 4 ולפרש את התגובה.
שליחת אירועים לצורך אימות
ההבדל היחיד בבקשה לאירועים שנשלחת ל-Measurement Protocol ולשרת האימות של Measurement Protocol הוא כתובת ה-URL.
שרת
כתובת URL
Measurement Protocol
/mp/collect
שרת האימות של Measurement Protocol
/debug/mp/collect
כל שאר שדות הבקשה זהים. למידע מלא על בניית בקשה תקפה, ראו את ההפניה לפרוטוקול.
בקוד הבא מוצג אירוע לא תקין שנשלח לשרת האימות של Measurement Protocol:
תשובת האימות
זו התשובה של שרת האימות לאירוע הקודם:
{"validationMessages":[{"fieldPath":"events","description":"Event at index: [0] has invalid name [_badEventName]. Names must start with an alphabetic character.","validationCode":"NAME_INVALID"}]}
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-05-28 (שעון UTC)."],[[["The Measurement Protocol Validation Server helps ensure your Google Analytics 4 events are correctly formatted before deploying to production."],["The Validation Server uses a different URL endpoint (`/debug/mp/collect`) than the standard Measurement Protocol (`/mp/collect`)."],["Validation responses provide detailed error messages including the field path, description, and a validation code for easier debugging."],["Events sent to the Validation Server are not processed and will not appear in your Google Analytics reports."],["The Google Analytics Event Builder offers an interactive way to construct and validate events before sending them to the server."]]],["To ensure valid events, use the Measurement Protocol Validation Server by sending requests to `/debug/mp/collect` instead of `/mp/collect`. Validate events before deploying them. This server doesn't log events in reports. It returns a response with `validationMessages`, an array detailing any errors like `NAME_INVALID`, `VALUE_REQUIRED`, or `VALUE_OUT_OF_BOUNDS`, specifying the `fieldPath`, `description`, and `validationCode` of the issue. Use the Google Analytics Event Builder for interactive event construction.\n"]]