Skip to main content
Glama
ambit1977

Google Tag Manager MCP Server

by ambit1977

create_trigger

Create triggers in Google Tag Manager to track user interactions like page views, clicks, custom events, form submissions, scroll depth, element visibility, YouTube video engagement, and timed actions.

Instructions

新しいトリガーを作成します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesアカウントID
containerIdYesコンテナID
workspaceIdYesワークスペースID
nameYesトリガー名
typeYesトリガータイプ(例: "PAGEVIEW", "CLICK", "CUSTOM_EVENT", "linkClick"など)
customEventFilterNoカスタムイベントフィルタ(CUSTOM_EVENTタイプ用)
filterNoフィルタ(linkClick、clickなどのタイプ用)
autoEventFilterNo自動イベントフィルタ(linkClickタイプ用)
waitForTagsNoタグの待機を有効化(linkClickタイプ用)
checkValidationNoバリデーションチェック(linkClickタイプ用)
waitForTagsTimeoutNoタグ待機タイムアウト(ミリ秒、linkClickタイプ用)
formIdNoフォームID(formSubmissionタイプ用)
formClassesNoフォームクラス(formSubmissionタイプ用)
verticalThresholdNo垂直スクロール閾値(パーセント、scrollDepthタイプ用)
horizontalThresholdNo水平スクロール閾値(パーセント、scrollDepthタイプ用)
selectorNoCSSセレクタ(elementVisibilityタイプ用)
visiblePercentageThresholdNo表示割合閾値(パーセント、elementVisibilityタイプ用)
continuousTimeMinMillisecondsNo連続表示時間(ミリ秒、elementVisibilityタイプ用)
videoIdNoYouTube動画ID(youtubeVideoタイプ用)
enableTriggerOnVideoStartNo動画開始時に発火(youtubeVideoタイプ用)
enableTriggerOnVideoProgressNo動画再生中に発火(youtubeVideoタイプ用)
enableTriggerOnVideoCompleteNo動画完了時に発火(youtubeVideoタイプ用)
enableTriggerOnVideoPauseNo動画一時停止時に発火(youtubeVideoタイプ用)
enableTriggerOnVideoSeekNo動画シーク時に発火(youtubeVideoタイプ用)
intervalNoインターバル(ミリ秒、timerタイプ用)
limitNo発火回数の上限(timerタイプ用)
startTimerOnNoタイマー開始タイミング(timerタイプ用、例: "windowLoad", "domReady")

Implementation Reference

  • Input schema definition for the create_trigger tool, including all parameters for different trigger types like filter, autoEventFilter, formId, etc.
    {
      name: 'create_trigger',
      description: '新しいトリガーを作成します',
      inputSchema: {
        type: 'object',
        properties: {
          accountId: {
            type: 'string',
            description: 'アカウントID',
          },
          containerId: {
            type: 'string',
            description: 'コンテナID',
          },
          workspaceId: {
            type: 'string',
            description: 'ワークスペースID',
          },
          name: {
            type: 'string',
            description: 'トリガー名',
          },
          type: {
            type: 'string',
            description: 'トリガータイプ(例: "PAGEVIEW", "CLICK", "CUSTOM_EVENT", "linkClick"など)',
          },
          customEventFilter: {
            type: 'array',
            description: 'カスタムイベントフィルタ(CUSTOM_EVENTタイプ用)',
          },
          filter: {
            type: 'array',
            description: 'フィルタ(linkClick、clickなどのタイプ用)',
          },
          autoEventFilter: {
            type: 'array',
            description: '自動イベントフィルタ(linkClickタイプ用)',
          },
          waitForTags: {
            type: 'boolean',
            description: 'タグの待機を有効化(linkClickタイプ用)',
          },
          checkValidation: {
            type: 'boolean',
            description: 'バリデーションチェック(linkClickタイプ用)',
          },
          waitForTagsTimeout: {
            type: 'number',
            description: 'タグ待機タイムアウト(ミリ秒、linkClickタイプ用)',
          },
          // formSubmission用
          formId: {
            type: 'string',
            description: 'フォームID(formSubmissionタイプ用)',
          },
          formClasses: {
            type: 'string',
            description: 'フォームクラス(formSubmissionタイプ用)',
          },
          // scrollDepth用
          verticalThreshold: {
            type: 'number',
            description: '垂直スクロール閾値(パーセント、scrollDepthタイプ用)',
          },
          horizontalThreshold: {
            type: 'number',
            description: '水平スクロール閾値(パーセント、scrollDepthタイプ用)',
          },
          // elementVisibility用
          selector: {
            type: 'string',
            description: 'CSSセレクタ(elementVisibilityタイプ用)',
          },
          visiblePercentageThreshold: {
            type: 'number',
            description: '表示割合閾値(パーセント、elementVisibilityタイプ用)',
          },
          continuousTimeMinMilliseconds: {
            type: 'number',
            description: '連続表示時間(ミリ秒、elementVisibilityタイプ用)',
          },
          // youtubeVideo用
          videoId: {
            type: 'string',
            description: 'YouTube動画ID(youtubeVideoタイプ用)',
          },
          enableTriggerOnVideoStart: {
            type: 'boolean',
            description: '動画開始時に発火(youtubeVideoタイプ用)',
          },
          enableTriggerOnVideoProgress: {
            type: 'boolean',
            description: '動画再生中に発火(youtubeVideoタイプ用)',
          },
          enableTriggerOnVideoComplete: {
            type: 'boolean',
            description: '動画完了時に発火(youtubeVideoタイプ用)',
          },
          enableTriggerOnVideoPause: {
            type: 'boolean',
            description: '動画一時停止時に発火(youtubeVideoタイプ用)',
          },
          enableTriggerOnVideoSeek: {
            type: 'boolean',
            description: '動画シーク時に発火(youtubeVideoタイプ用)',
          },
          // timer用
          interval: {
            type: 'number',
            description: 'インターバル(ミリ秒、timerタイプ用)',
          },
          limit: {
            type: 'number',
            description: '発火回数の上限(timerタイプ用)',
          },
          startTimerOn: {
            type: 'string',
            description: 'タイマー開始タイミング(timerタイプ用、例: "windowLoad", "domReady")',
          },
        },
        required: ['accountId', 'containerId', 'workspaceId', 'name', 'type'],
      },
    },
  • MCP tool handler for 'create_trigger'. Processes input arguments, applies type-specific configurations (e.g., filters for linkClick/formSubmission/youtubeVideo/etc.), constructs the triggerData object, and calls GTMClient.createTrigger to perform the API call.
    case 'create_trigger': {
      const triggerData = {
        name: args.name,
        type: args.type,
      };
    
      // カスタムイベントフィルタ(CUSTOM_EVENTタイプ用)
      if (args.customEventFilter) {
        triggerData.customEventFilter = args.customEventFilter;
      }
    
      // フィルタ(linkClick、clickなどのタイプ用)
      if (args.filter) {
        // JSON文字列の場合は配列に変換
        if (typeof args.filter === 'string') {
          try {
            triggerData.filter = JSON.parse(args.filter);
          } catch (e) {
            triggerData.filter = args.filter;
          }
        } else {
          triggerData.filter = args.filter;
        }
      }
    
      // 自動イベントフィルタ(linkClickタイプ用)
      if (args.autoEventFilter) {
        // JSON文字列の場合は配列に変換
        if (typeof args.autoEventFilter === 'string') {
          try {
            triggerData.autoEventFilter = JSON.parse(args.autoEventFilter);
          } catch (e) {
            triggerData.autoEventFilter = args.autoEventFilter;
          }
        } else {
          triggerData.autoEventFilter = args.autoEventFilter;
        }
      }
    
      // タグ待機設定(linkClickタイプ用)
      if (args.waitForTags !== undefined) {
        triggerData.waitForTags = {
          type: 'boolean',
          value: String(args.waitForTags)
        };
      }
    
      // バリデーションチェック(linkClickタイプ用)
      if (args.checkValidation !== undefined) {
        triggerData.checkValidation = {
          type: 'boolean',
          value: String(args.checkValidation)
        };
      }
    
      // タグ待機タイムアウト(linkClickタイプ用)
      if (args.waitForTagsTimeout !== undefined) {
        triggerData.waitForTagsTimeout = {
          type: 'template',
          value: String(args.waitForTagsTimeout)
        };
      }
    
      // formSubmission用
      if (args.type === 'formSubmission') {
        triggerData.filter = [];
        if (args.formId) {
          triggerData.filter.push({
            type: 'contains',
            parameter: [
              {
                type: 'template',
                key: 'arg0',
                value: '{{Form ID}}'
              },
              {
                type: 'template',
                key: 'arg1',
                value: args.formId
              }
            ]
          });
        }
        if (args.formClasses) {
          triggerData.filter.push({
            type: 'contains',
            parameter: [
              {
                type: 'template',
                key: 'arg0',
                value: '{{Form Classes}}'
              },
              {
                type: 'template',
                key: 'arg1',
                value: args.formClasses
              }
            ]
          });
        }
      }
    
      // scrollDepth用
      if (args.type === 'scrollDepth') {
        triggerData.parameter = [
          {
            type: 'template',
            key: 'verticalThresholdUnits',
            value: 'PERCENT'
          },
          {
            type: 'template',
            key: 'verticalThreshold',
            value: String(args.verticalThreshold || 25)
          }
        ];
        if (args.horizontalThreshold !== undefined) {
          triggerData.parameter.push(
            {
              type: 'template',
              key: 'horizontalThresholdUnits',
              value: 'PERCENT'
            },
            {
              type: 'template',
              key: 'horizontalThreshold',
              value: String(args.horizontalThreshold)
            }
          );
        }
      }
    
      // elementVisibility用
      if (args.type === 'visible' || args.type === 'elementVisibility') {
        triggerData.type = 'visible';
        triggerData.parameter = [
          {
            type: 'template',
            key: 'selector',
            value: args.selector || ''
          },
          {
            type: 'template',
            key: 'visiblePercentageThreshold',
            value: String(args.visiblePercentageThreshold || 50)
          },
          {
            type: 'template',
            key: 'continuousTimeMinMilliseconds',
            value: String(args.continuousTimeMinMilliseconds || 0)
          }
        ];
      }
    
      // youtubeVideo用
      if (args.type === 'youtubeVideo') {
        triggerData.parameter = [
          {
            type: 'template',
            key: 'enableTriggerOnVideoStart',
            value: String(args.enableTriggerOnVideoStart || false)
          },
          {
            type: 'template',
            key: 'enableTriggerOnVideoProgress',
            value: String(args.enableTriggerOnVideoProgress || false)
          },
          {
            type: 'template',
            key: 'enableTriggerOnVideoComplete',
            value: String(args.enableTriggerOnVideoComplete || false)
          },
          {
            type: 'template',
            key: 'enableTriggerOnVideoPause',
            value: String(args.enableTriggerOnVideoPause || false)
          },
          {
            type: 'template',
            key: 'enableTriggerOnVideoSeek',
            value: String(args.enableTriggerOnVideoSeek || false)
          }
        ];
        if (args.videoId) {
          triggerData.filter = [
            {
              type: 'equals',
              parameter: [
                {
                  type: 'template',
                  key: 'arg0',
                  value: '{{Video ID}}'
                },
                {
                  type: 'template',
                  key: 'arg1',
                  value: args.videoId
                }
              ]
            }
          ];
        }
      }
    
      // timer用
      if (args.type === 'timer') {
        triggerData.parameter = [
          {
            type: 'template',
            key: 'interval',
            value: String(args.interval || 1000)
          },
          {
            type: 'template',
            key: 'limit',
            value: String(args.limit || 1)
          },
          {
            type: 'template',
            key: 'startTimerOn',
            value: args.startTimerOn || 'windowLoad'
          }
        ];
      }
    
      // linkClickタイプの場合、waitForTags、checkValidation、waitForTagsTimeoutが未設定の場合はデフォルト値を設定
      if (triggerData.type === 'linkClick') {
        if (triggerData.waitForTags === undefined) {
          triggerData.waitForTags = {
            type: 'template'
          };
        }
        if (triggerData.checkValidation === undefined) {
          triggerData.checkValidation = {
            type: 'template'
          };
        }
        if (triggerData.waitForTagsTimeout === undefined) {
          triggerData.waitForTagsTimeout = {
            type: 'template'
          };
        }
        if (!triggerData.uniqueTriggerId) {
          triggerData.uniqueTriggerId = {
            type: 'template'
          };
        }
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(
              await this.gtmClient.createTrigger(
                args.accountId,
                args.containerId,
                args.workspaceId,
                triggerData
              ),
              null,
              2
            ),
          },
        ],
      };
    }
  • Core implementation in GTMClient that makes the actual Google Tag Manager API call to create the trigger using the googleapis library.
     */
    async createTrigger(accountId, containerId, workspaceId, triggerData) {
      await this.ensureAuth();
      const response = await this.tagmanager.accounts.containers.workspaces.triggers.create({
        parent: `accounts/${accountId}/containers/${containerId}/workspaces/${workspaceId}`,
        requestBody: triggerData
      });
      return response.data;
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Creates a new trigger' implies a write/mutation operation, but the description doesn't mention whether this requires specific permissions, what happens on success/failure, whether the trigger is immediately active, or any side effects. For a creation tool with 27 parameters and no annotation coverage, this is completely inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While technically concise (one sentence), this is a case of under-specification rather than effective brevity. The single sentence doesn't earn its place by providing any meaningful information beyond the tool name. For a complex tool with 27 parameters, this level of conciseness is detrimental to understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

This is a creation/mutation tool with no annotations, no output schema, and 27 parameters. The description is completely inadequate for the complexity involved. It doesn't explain what a trigger is, what system it operates in, what happens after creation, or provide any context about the rich parameter set. Given the absence of structured metadata, the description should do much more heavy lifting.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, meaning all 27 parameters are documented in the input schema itself. The description adds zero additional information about parameters, not even mentioning that different parameters apply to different trigger types. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, though the description provides no value beyond what's already in the structured data.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '新しいトリガーを作成します' (creates a new trigger) is a tautology that essentially restates the tool name 'create_trigger'. It doesn't specify what kind of trigger, what system it's for, or how it differs from sibling tools like 'update_trigger' or 'delete_trigger'. While it contains a verb and resource, it's too generic to be helpful for an AI agent.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides absolutely no guidance on when to use this tool versus alternatives. There's no mention of prerequisites (like authentication), when to choose this over 'update_trigger', what happens after creation, or any context about the trigger lifecycle. Given the complex sibling toolset including authentication and other trigger operations, this is a critical omission.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ambit1977/GTM-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server