How to use GTM's custom JavaScript to fire tags under certain conditions

Taiwan Data Forum trends and innovations
Post Reply
mehadihasan123
Posts: 217
Joined: Wed Dec 11, 2024 4:52 am

How to use GTM's custom JavaScript to fire tags under certain conditions

Post by mehadihasan123 »

In today's ad operations, it is common to use the platform's automatic bidding function. Designing micro-conversions and negative conversions has also become an important part of the ad manager's job, and the use of tag management tools has also increased.

One area where beginners to tag management often get stuck is when they cannot use a URL as a trigger condition.

This time, we will introduce a way to use nigeria phone number resource Google Tag Manager (GTM) custom JavaScript to trigger tags under specific conditions in cases like the one above.

Image

Table of Contents [ Hide ]

What is GTM Custom JavaScript?
Variable design for each case - Tag implementation
Case 1: A multi-product e-commerce site promoting only one product
Case 2: A human resources service that aims to register members, where the outcome definition is only those who hold certain qualifications
What is GTM Custom JavaScript?
This is a type of "user-defined variable" that obtains the value of a specified variable, and is a function that literally allows you to use original JavaScript.

When you select "Variable type: Custom JavaScript" on the user-defined variable editing screen, a free form will be displayed where you can write any JavaScript you like.


Custom JavaScript must be in the form of an anonymous function that returns a value , so your JavaScript must start with "function(){" and end with "}", and the function must return a value in the form "return ○○".

Reference: User-defined variable types for the Web

For example, if you want to return the value 100 using custom JavaScript, you would write it like this:

function(){
return 100;
}

The advantage of custom JavaScript is that it allows you to retrieve page elements with great flexibility . However, because of this high degree of freedom, it requires knowledge of JavaScript that allows you to design it while taking into account the specifications of the website.
Post Reply