GTM Sandboxed API IntelliSense
Updated Sep 17, 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
1. Download the TypeScript Declaration File

The folder you downloaded contains two files. Choose the .d.ts file that matches your GTM environment:
- server-gtm-sandboxed-apis.d.ts — for server-side GTM templates.
- web-gtm-sandboxed-apis.d.ts — for web GTM templates.

2. Add GTM Sandboxed API IntelliSense to your project
Place the selected .d.ts file inside your project directory. The root folder of your custom GTM template project is recommended.
3. Activate IntelliSense in your editor
There are two ways to enable IntelliSense using the type declarations:
Method 1: Triple-Slash Reference (File-by-File)
1. Place the .d.ts file in the same folder as your GTM template JavaScript file.
2. At the very top of your JavaScript file, add a triple-slash reference:
/// <reference path="./web-gtm-sandboxed-apis.d.ts" />
// Your GTM template code follows here...
3. Make sure the path in the reference matches the actual location of your .d.ts file (web or server).
Method 2: Using jsconfig.json (Project-Wide)
1. Place the .d.ts file in your project’s root directory.
2. Create a file in the root folder named jsconfig.json with the following content:
{
"compilerOptions": {
"target": "esnext"
},
"include": ["**/*"]
}
3. Restart or reload your editor window if IntelliSense does not appear immediately.
4. 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

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