با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
نصبهای تگ Google را میتوان برای هدایت دادهها به گروههای خاصی از حسابها یا محصولات پیکربندی کرد. راهحلهای اندازهگیری کامل برای محصولات اندازهگیری Google را میتوان از داخل یک بلوک کد پیکربندی کرد. این راهنما نحوه پیکربندی تگ Google را برای ارسال داده به محصولات، حسابها و پیکربندیهای خاص با استفاده از پارامترهای send_to و groups توضیح میدهد.
مسیریابی پیش فرض
تگ Google شما حاوی یک فرمان config برای مدیریت مسیریابی است. به عنوان مثال، وقتی تگ Google را با شناسه برچسب نصب میکنید، قطعه زیر دادهها را به Google Analytics 4، حسابهای Google Ads یا هر دو ارسال میکند:
gtag('config','TAG_ID');
با افزودن پارامتر send_to به دستورات event ، میتوانید مسیری را که در تگ Google (یا هر دستورالعمل مسیریابی قبلی در صفحه) مشخص شده است، لغو کنید.
برای مثال، رویداد sign_in زیر فقط به یک ویژگی Google Analytics با شناسه مقصد'G-XXXXXX-2' ارسال میشود، صرف نظر از اینکه کدام هدف قبلاً در صفحه پیکربندی شده است.
gtag('event','sign_in',{'send_to':'G-XXXXXX-2'});
گروه ها
گاهی اوقات ممکن است لازم باشد اطلاعات خاصی را به مجموعه ای از حساب ها یا محصولات ارسال کنید و سایر اطلاعات را به مجموعه دیگری از حساب ها یا محصولات ارسال کنید. به عنوان مثال، ممکن است بخواهید اطلاعاتی در مورد کمپین های بازاریابی خاص به آژانس تبلیغاتی خود ارسال کنید، در حالی که اطلاعات کامل تری را برای سازمان خود حفظ کنید. این عملکرد را می توان با استفاده از groups سازماندهی کرد.
میتوانید گروهی از اهداف (مثلاً محصولات، حسابها و ویژگیها) ایجاد کنید و سپس رویدادها را به آن گروه هدایت کنید.
در مثال زیر، دو ویژگی Google Analytics به گروهی به نام group1 اضافه شده است. سپس، یک رویداد sign_in به دو ویژگی آن گروه هدایت می شود.
gtag('config','G-XXXXXX-1',{'groups':'group1'});gtag('config','G-XXXXXX-2',{'groups':'group1'});// Routes to 'G-XXXXXX-1' and 'G-XXXXXX-2'gtag('event','sign_in',{'send_to':'group1'});
گروه پیش فرض
اگر پارامتر send_to تنظیم نشده باشد، رویدادها به گروه هدف default هدایت میشوند. گروه default شامل تمام محصولات و حسابهای دستورات config در صفحه است که قبل از رویداد اجرا شدهاند. حتی اگر پارامتر groups در دستور config مشخص نشده باشد، هدف به گروه default اختصاص داده می شود.
// The following two lines are equivalent:gtag('config','G-XXXXXX-1');gtag('config','G-XXXXXX-1',{'groups':'default'});
مثال بعدی نشان میدهد که رویدادها به گروه default ارسال میشوند، صرف نظر از اینکه {'send_to : 'default'} مشخص شده باشد.
// Configure a targetgtag('config','G-XXXXXX-1');// Since send_to is not specified, this routes to the 'default' group which// includes 'G-XXXXXX-1', as defined in config, above.gtag('event','sign_in');// By default, routes to the 'default' groups which includes// 'G-XXXXXX-1', as defined in config, above.gtag('event','generate_lead',{'send_to':'default'});
مسیر به groups سفارشی
با استفاده از groups ، میتوانید قطعات خاصی از دادهها را که باید به مجموعهای از شناسهها هدایت شوند، شناسایی کنید. نمونه کد زیر نحوه مسیریابی داده های رویداد sign_in به یک گروه سفارشی به نام agency نشان می دهد.
// Configure a targetgtag('config','G-XXXXXX-1');gtag('config','G-XXXXXX-3',{'groups':'agency'});gtag('config','G-XXXXXX-9',{'groups':'agency'});// Routes only to 'G-XXXXXX-3' and 'G-XXXXXX-9' since they// are both in the 'agency' groupgtag('event','sign_in',{'send_to':'agency'});
مثال: Google Ads، Analytics، Floodlight را با هم پیکربندی کنید
میتوانید پیکربندیهای کاملی برای Google Ads، Google Analytics و Floodlight از داخل یک تگ Google ایجاد کنید. این مثال نشان می دهد که یک تگ ترکیبی چگونه ممکن است به نظر برسد. این مثال:
داده های مشاهده صفحه را به Google Analytics ارسال می کند
تبدیل Google Ads و Floodlight را اندازه گیری می کند
اطلاعات مربوط به یک کالای اضافه شده به سبد خرید را به Analytics و Google Ads ارسال می کند
تاریخ آخرین بهروزرسانی 2024-11-18 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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"]],["تاریخ آخرین بهروزرسانی 2024-11-18 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eGoogle tag installations can be customized to send data to specific Google products and accounts, streamlining your measurement setup.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esend_to\u003c/code\u003e parameter allows you to override default routing and direct specific events to designated destinations like Google Analytics properties or custom groups.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGroups\u003c/code\u003e enable you to organize multiple targets (accounts, products) for efficient data routing, such as sending campaign data to an agency while retaining detailed data internally.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edefault\u003c/code\u003e group automatically includes all configured targets, ensuring data is sent to all intended destinations unless otherwise specified using \u003ccode\u003esend_to\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eGoogle tag supports comprehensive configurations for Google Ads, Analytics, and Floodlight within the same code block, allowing for holistic measurement across platforms.\u003c/p\u003e\n"]]],["The Google tag uses `config` commands to route data to specified accounts or products. The `send_to` parameter in `event` commands can override this routing, directing data to specific destinations. `Groups` allows routing to sets of targets. The `default` group includes all previously configured targets. Data can be routed to custom-defined groups. A single Google tag can configure complete solutions for multiple Google products such as Google Ads, Analytics, and Floodlight, shown by example.\n"],null,["# Group and route data\n\nInstallations of the Google tag can be configured to route data to\nspecific groups of accounts or products. Complete measurement solutions for\nGoogle measurement products can be configured all from within the same code\nblock. This guide explains how to configure the Google tag to send data to\nspecific products, accounts, and configurations using the `send_to` and `groups`\nparameters.\n\nDefault routing\n---------------\n\nYour Google tag contains a `config` command to handle routing. For example,\nwhen you install the Google tag with a\n[tag ID](https://support.google.com/tagmanager/answer/12326985), the following\nsnippet sends data to your Google Analytics 4, Google Ads accounts, or both: \n\n gtag('config', 'TAG_ID');\n\nYou can override the routing that's specified in the Google tag (or any\nearlier routing instructions on the page) by adding the `send_to` parameter to\n`event` commands.\n\nFor example, the following `sign_in` event is only sent to a Google Analytics\nproperty with the\n[destination ID](https://support.google.com/tagmanager/answer/12324787) `'G-XXXXXX-2'`, regardless of which targets were previously configured on the page. \n\n gtag('event', 'sign_in', { 'send_to': 'G-XXXXXX-2' });\n\nGroups\n------\n\nSometimes you may need to send certain information to a set of accounts or\nproducts, and send other pieces of information to another set of accounts or\nproducts. For example, you may want to send information about specific marketing\ncampaigns to your ad agency, while retaining more complete data for your\norganization. This functionality can be organized using `groups`.\n\nYou can create a group of targets (e.g. products, accounts, and properties) and\nthen route events to that group.\n| **Note:** Group names can't contain a dash.\n\nIn the following example, two Google Analytics\nproperties are added to a group named `group1`. Then, a `sign_in` event is\nrouted to the two properties in that group. \n\n gtag('config', 'G-XXXXXX-1', { 'groups': 'group1' });\n gtag('config', 'G-XXXXXX-2', { 'groups': 'group1' });\n\n // Routes to 'G-XXXXXX-1' and 'G-XXXXXX-2'\n gtag('event', 'sign_in', { 'send_to': 'group1' });\n\n### Default group\n\nIf a `send_to` parameter is not set, events are routed to the `default` target\ngroup. The `default` group includes all products and accounts from `config`\ncommands on the page that have executed prior to the event. Even if the `groups`\nparameter is not specified in a `config` command, the target is assigned to the\n`default` group. \n\n // The following two lines are equivalent:\n gtag('config', 'G-XXXXXX-1');\n gtag('config', 'G-XXXXXX-1', { 'groups': 'default' });\n\nThe next example illustrates that events are sent to the `default` group,\nregardless of whether `{'send_to : 'default'}` is specified. \n\n // Configure a target\n gtag('config', 'G-XXXXXX-1');\n\n // Since send_to is not specified, this routes to the 'default' group which\n // includes 'G-XXXXXX-1', as defined in config, above.\n gtag('event', 'sign_in');\n\n // By default, routes to the 'default' groups which includes\n // 'G-XXXXXX-1', as defined in config, above.\n gtag('event', 'generate_lead', { 'send_to': 'default' });\n\n### Route to custom `groups`\n\nUsing `groups`, you can identify certain pieces of data that should be routed to\na specific set of IDs. The following code sample illustrates how to route\n`sign_in` event data to a custom group called `agency`. \n\n // Configure a target\n gtag('config', 'G-XXXXXX-1');\n gtag('config', 'G-XXXXXX-3', { 'groups': 'agency' });\n gtag('config', 'G-XXXXXX-9', { 'groups': 'agency' });\n\n // Routes only to 'G-XXXXXX-3' and 'G-XXXXXX-9' since they\n // are both in the 'agency' group\n gtag('event', 'sign_in', { 'send_to': 'agency' });\n\nExample: Configure Google Ads, Analytics, Floodlight together\n-------------------------------------------------------------\n\nYou can create complete configurations for Google Ads, Google Analytics, and\nFloodlight all from within the same Google tag. This example\ndemonstrates what a combined tag might look like. This example:\n\n- Sends pageview data to Google Analytics\n- Measures Google Ads and Floodlight conversions\n- Sends information about an item added to a shopping cart to Analytics and Google Ads\n\n \u003cscript async src=\"https://www.googletagmanager.com/gtag/js?id=TAG_ID\"\u003e\n \u003c/script\u003e\n \u003cscript\u003e\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n\n // Global configs\n gtag('config', 'TAG_ID');\n gtag('config', 'DC-ZZZZZZ');\n\n // Measure Google Ads conversions\n gtag('event', 'conversion', {\n 'send_to': 'AW-YYYYYY/AbC-D_efG-h12_34-567',\n 'value': 1.0,\n 'currency': 'USD'\n });\n\n // Measure Floodlight conversions\n gtag('event', 'conversion', {\n 'allow_custom_scripts': true,\n 'send_to': 'DC-ZZZZZZ/actions/locat304+standard'\n });\n\n // Route ecommerce add_to_cart event to Google Ads and Analytics\n gtag('event', 'add_to_cart', {\n 'send_to': [\n 'G-XXXXXX-1',\n 'AW-YYYYYY'\n ],\n 'items': [\n 'id': 'U1234',\n 'ecomm_prodid': 'U1234',\n 'name': 'Argyle Funky Winklepickers',\n 'list': 'Search Results',\n 'category': 'Footwear',\n 'quantity': 1,\n 'ecomm_totalvalue': 123.45,\n 'price': 123.45\n ]\n });\n \u003c/script\u003e"]]