একটি কাস্টম ভেরিয়েবল তৈরি করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
একটি কাস্টম ভেরিয়েবল টেমপ্লেট কীভাবে তৈরি করবেন তা এই গাইডটি আপনাকে নিয়ে যাবে। যখন এই ভেরিয়েবলটি ব্যবহার করা হয়, তখন এটি মানগুলির একটি অ্যারে নেবে এবং তাদের একটি কমা সীমাবদ্ধ স্ট্রিং হিসাবে ফেরত দেবে।
আপনার প্রথম পরিবর্তনশীল টেমপ্লেট শুরু করতে, বাম নেভিগেশনে টেমপ্লেট ক্লিক করুন এবং পরিবর্তনশীল টেমপ্লেট বিভাগের অধীনে নতুন বোতামে ক্লিক করুন।
তথ্য ট্যাবে, ভেরিয়েবলের নাম এবং বিবরণ সংজ্ঞায়িত করুন।
ব্যবহারকারীরা যখন ট্যাগ ম্যানেজার ইউজার ইন্টারফেস জুড়ে এই ভেরিয়েবলটি প্রয়োগ করতে যায় তখন তাদের কাছে নামটি উপস্থাপন করা হবে।
বর্ণনার মত শোনাচ্ছে - এই ভেরিয়েবল কি করে তার একটি সংক্ষিপ্ত (200 অক্ষর বা কম) বর্ণনা।
আপনার টেমপ্লেট পূর্বরূপ দেখতে রিফ্রেশ ক্লিক করুন.
ফিল্ড ইনপুটগুলির ডানদিকে, একটি টেমপ্লেট প্রিভিউ উইন্ডো রয়েছে। প্রতিবার সম্পাদকে পরিবর্তন করা হলে, রিফ্রেশ বোতামটি প্রদর্শিত হবে। আপনার পরিবর্তনগুলি আপনার ভেরিয়েবলের উপস্থিতিতে কী করে তা দেখতে রিফ্রেশ ক্লিক করুন৷
আপনার পরিবর্তনশীল টেমপ্লেটে ক্ষেত্র যোগ করতে ক্ষেত্রগুলিতে ক্লিক করুন।
টেমপ্লেট এডিটরের ফিল্ড ট্যাব আপনাকে পরিবর্তনশীল টেমপ্লেটে ক্ষেত্র তৈরি ও সম্পাদনা করতে দেয়। ক্ষেত্রগুলি কাস্টম ডেটা প্রবেশ করতে ব্যবহৃত হয়, যেমন একটি অ্যাকাউন্ট আইডি। আপনি টেক্সট ক্ষেত্র, ড্রপ ডাউন মেনু, রেডিও বোতাম এবং চেকবক্সের মতো স্ট্যান্ডার্ড ফর্ম উপাদান যোগ করতে পারেন।
ক্ষেত্র যোগ করুন ক্লিক করুন এবং সরল টেবিল নির্বাচন করুন। ডিফল্ট নাম (যেমন "simpleTable1" ) "list" দিয়ে প্রতিস্থাপন করুন। টেমপ্লেট প্রিভিউতে , রিফ্রেশ ক্লিক করুন।
একটি টেক্সট ইনপুটের জন্য এই ধাপটি পুনরাবৃত্তি করুন এবং এটিকে "অ্যারে" বলুন, দুটি চেকবক্সকে " use_array " এবং "sort" বলা হয়, এবং একটি টেক্সট ইনপুট যাকে "ডেলিমিটার" বলা হয়। "ডিলিমিটার" এর জন্য, গিয়ার আইকনে ক্লিক করে, "ডিফল্ট মান" চালু করে এবং তারপর নতুন ডিফল্ট মান ইনপুট ক্ষেত্রটি পূরণ করে এটিকে "," এর একটি ডিফল্ট মান দিন৷
কোড ট্যাবে ক্লিক করুন এবং সম্পাদকে স্যান্ডবক্সযুক্ত জাভাস্ক্রিপ্ট লিখুন:
var input = data.array;
if (!data.use_array) {
input = [];
for (var i = 0; i < data.list.length; i++) {
input.push(data.list[i].values);
}
}
if (data.sort) {
input.sort();
}
return input.join(data.delimiter || ',');
এই ভেরিয়েবলের কোডটি মোটামুটি সহজবোধ্য, কিন্তু কিছু জিনিস উল্লেখ করার মতো।
data
ক্ষেত্র।
কিছু ক্ষেত্র রয়েছে যা বিশ্বব্যাপী data
থেকে অ্যাক্সেস করা হচ্ছে। data
আপনার আগের ধাপে সেট আপ করা মানগুলি থাকবে। এজন্য আমরা data.use_array
, data.sort
, data.list
, এবং data.delimiter
অ্যাক্সেস করতে সক্ষম হয়েছি।
যদি data.delimiter
প্রদান না করা হয় তবে delimiter
একটি ডিফল্ট মান ","
সেট করা হয়। একটি ক্ষেত্রের জন্য ডিফল্ট মান সেট করা একটি ভাল অভ্যাস যদি কেউ বোধগম্য হয়। এটি ব্যবহারকারীদের জন্য পরিবর্তনশীল টেমপ্লেট ব্যবহার করা সহজ করে তোলে, যেহেতু তাদের ভেরিয়েবল ব্যবহার করার জন্য প্রতিটি ক্ষেত্র পূরণ করতে হবে না।
আপনার অগ্রগতি সংরক্ষণ করতে সংরক্ষণ করুন ক্লিক করুন. এটি টেমপ্লেট এডিটরে যেকোনো সনাক্ত করা অনুমতি লোড করবে।
কিছু টেমপ্লেট API-এর সাথে সংশ্লিষ্ট অনুমতি রয়েছে যা নির্দেশ করে যে তারা কী করতে পারে বা কী করতে পারে না। আপনি যখন আপনার কোডে sendPixel
এর মতো একটি টেমপ্লেট API ব্যবহার করেন, তখন ট্যাগ ম্যানেজার অনুমতি ট্যাবে প্রাসঙ্গিক অনুমতি দেখাবে।
টেমপ্লেট প্রিভিউ ট্যাবে, "মান" ইনপুটের জন্য কিছু মান যোগ করুন, রান কোড এ ক্লিক করুন এবং আপনার ভেরিয়েবলের আউটপুট দেখতে কনসোলটি দেখুন।
যদি কোন ত্রুটি থাকে, তারা কনসোল উইন্ডোতে প্রদর্শিত হবে।
সেভ এ ক্লিক করুন এবং টেমপ্লেট এডিটর বন্ধ করুন
পরিবর্তনশীল টেমপ্লেটটি এখন ব্যবহারের জন্য প্রস্তুত হওয়া উচিত।
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis guide provides step-by-step instructions to create a custom variable template in Google Tag Manager.\u003c/p\u003e\n"],["\u003cp\u003eThis template transforms an array of values into a comma-separated string using JavaScript code within the template.\u003c/p\u003e\n"],["\u003cp\u003eThe template utilizes fields like 'list', 'array', 'use_array', 'sort', and 'delimiter' to customize its functionality.\u003c/p\u003e\n"],["\u003cp\u003eUsers can preview and test the template using the 'Template Preview' and 'Console' sections within the editor.\u003c/p\u003e\n"],["\u003cp\u003eOnce saved, the custom variable template is ready to be implemented within Google Tag Manager.\u003c/p\u003e\n"]]],["To create a variable template that returns a comma-delimited string from an array, start by creating a new template, defining its name and description in the *Info* tab. Then, in the *Fields* tab, add fields for a simple table (\"list\"), text input (\"array\"), checkboxes (\"use_array\", \"sort\"), and text input (\"delimiter\"). In the *Code* tab, enter sandboxed JavaScript to process these fields, joining the array with the specified delimiter, and save. Then preview the result and save the variable.\n"],null,["# Create a custom variable\n\nThis guide will walk you through how to create a custom variable template. When\nthis variable is used, it will take an array of values and return them as a\ncomma delimited string.\n\n1. To begin your first variable template, click Templates in the left\n navigation and click the *New* button under the *Variable Templates*\n section.\n\n2. In the *Info* tab, define the variable's *Name* and *Description*.\n\n **Name** is what will be presented to users when they go to implement this\n variable throughout the Tag Manager user interface.\n\n **Description** is just what it sounds like - a brief (200 characters or\n less) description of what this variable does.\n3. Click *Refresh* to preview your template.\n\n To the right of the field inputs, there is a *Template Preview* window.\n Every time a change is made in the editor, the **Refresh** button will\n appear. Click Refresh to see what your changes do to the appearance of your\n variable.\n4. Click *Fields* to add fields to your variable template.\n\n The Template Editor's **Fields** tab lets you create and edit fields in the\n variable template. Fields are used to enter custom data, such as an account\n ID. You can add the standard form elements like text fields, drop down\n menus, radio buttons, and checkboxes.\n5. Click *Add Field* and select *Simple table* . Replace the default name (e.g.\n *\"simpleTable1\"* ) with *\"list\"* . In the *Template Preview* , click *Refresh*.\n\n Repeat this step for a *Text Input* and call it *\"array\"* , two *Checkboxes*\n called \"*use_array* \" and *\"sort\"* , and a *Text Input* called *\"delimiter\"* .\n For *\"delimiter\"* , give it a default value of \",\" by clicking the gear icon,\n toggling *\"Default value\"* to on, and then filling in the new Default Value\n input field.\n6. Click the *Code* tab and enter sandboxed JavaScript in the editor:\n\n var input = data.array;\n\n if (!data.use_array) {\n input = [];\n for (var i = 0; i \u003c data.list.length; i++) {\n input.push(data.list[i].values);\n }\n }\n\n if (data.sort) {\n input.sort();\n }\n\n return input.join(data.delimiter || ',');\n\n The code for this variable is fairly straightforward, but there are a few\n things worth pointing out.\n - `data` fields.\n\n There are a few fields that are being accessed off of the `data` global.\n `data` will contain the values that you set up in the previous step.\n That's why we're able to access `data.use_array`, `data.sort`,\n `data.list`, and `data.delimiter`.\n - `delimiter` is set to a default value of `\",\"` if `data.delimiter` is\n not provided. It's a good practice to set default values for a field if\n one makes sense. This makes it easier for users to use the variable\n template, since they don't have to fill out every field in order to use\n the variable.\n\n7. Click *Save* to save your progress. This will load any detected permissions\n into the Template Editor.\n\n Some Template APIs have [permissions](/tag-platform/tag-manager/templates/permissions) associated with them that dictate what\n they can or cannot do. When you use a template API such as `sendPixel` in\n your code, Tag Manager will show relevant permissions in the **Permissions**\n tab.\n8. In the *Template Preview* tab, add some values for the \"values\" input, click\n **Run Code** , and look at the *Console* to see the output for your variable.\n\n If there are any errors, they will appear in the **Console** window.\n9. Click *Save*, and close the Template Editor\n\n The variable template should now be ready for use."]]