GTM Sandboxed API IntelliSense
Updated Nov 7, 2025
This guide shows how to use the included TypeScript declaration files (.d.ts) to enable IntelliSense features, such as autocompletion and hover documentation, for Google Tag Manager’s Sandboxed JavaScript APIs in your code editor.
What is GTM Sandboxed API IntelliSense?
GTM Sandboxed API IntelliSense is TypeScript declarations for autocompletion of Google Tag Manager APIs in code editors.
Google Tag Manager uses an isolated JavaScript environment with a limited set of APIs for security reasons. Instead of standard fetch(), document.cookie, etc., special functions such as sendHttpRequest() and getCookieValues() are available.
The challenge
Standard code editors are unaware of these APIs, so they lack autocomplete, parameter hints, and documentation, making it difficult to identify errors.
IntelliSense solves all these problems.
How to integrate GTM Sandboxed API IntelliSense
Check whether the package managers for Node.js are installed
To check if you have Node.js and npm installed and their installed version, run the following commands:
node -v
npm -vAlternatively, if you prefer to use pnpm over npm, verify that pnpm is installed. Run the command:
pnpm --version
2. If you don't have them installed, follow the instructions:
3. Install the type definitions using a package manager you’ve chosen (npm or pnpm) in the root of the folder that contains your GTM template JavaScript file:
pnpm install -D stape-gtm-api-types
# or
npm install --save-dev stape-gtm-api-types
Activate IntelliSense in your editor
There are two ways to use IntelliSense:
Method 1: Triple-Slash Reference (File-by-File)
This approach is helpful if you’d rather not create a jsconfig.json file (as described in Method 2 below).
- To activate IntelliSense for GTM Sandboxed API code, you’ll need to place a specific comment at the very top of each JavaScript file.
Make sure to include this comment exactly as shown (with the triple slashes) at the beginning of every JavaScript file where you want IntelliSense.
- For Web GTM Sandboxed API:
/// <reference types="stape-gtm-api-types/web-gtm-sandboxed-apis" />
// Your GTM template code starts here...
const copyFromDataLayer = require('copyFromDataLayer');- For Server GTM Sandboxed APIs:
/// <reference types="stape-gtm-api-types/server-gtm-sandboxed-apis" />
// Your GTM template code starts here...
const getAllEventData = require('getAllEventData');2. Restart or reload your editor window if IntelliSense does not appear immediately.
Method 2: Using jsconfig.json (Project-Wide)
- Create a jsconfig.json file with the following content in the root directory of your project, where your template code is located.
- For Web GTM Sandboxed APIs:
{
"compilerOptions": {
"paths": {
"*": ["./node_modules/stape-gtm-api-types/web-gtm-sandboxed-apis"]
}
},
"include": ["**/*"]
}
- For Server GTM Sandboxed APIs
{
"compilerOptions": {
"paths": {
"*": ["./node_modules/stape-gtm-api-types/server-gtm-sandboxed-apis"]
}
},
"include": ["**/*"]
}
2. Restart or reload your editor window if IntelliSense does not appear immediately.
Regardless of the method you’ve chosen, make sure to periodically run the following command in the folder that contains your GTM template JavaScript files. This will make sure you receive any Intellisense updates.
npm update
# or
pnpm update
Start Coding
With IntelliSense enabled, your code editor will now:
- Suggest GTM API names as you type
- Show parameter info for GTM-specific functions
- Display documentation and type hints automatically

GTM Sandboxed API IntelliSense examples
Check examples demonstrating GTM Sandboxed API IntelliSense on our GitHub repository.
Conclusion
The Google Tag Manager Sandboxed API IntelliSense package is an essential tool for developers working with GTM custom templates. By providing TypeScript declaration files for GTM's unique sandboxed JavaScript environment, it enables autocompletion, inline documentation, and error detection in code editors. This significantly improves coding efficiency, reduces mistakes, and speeds up template development.
Comments