Install Deway via Google Tag Manager
Install and configure Deway using Google Tag Manager (GTM) without modifying your application code.
Prerequisites
- Google Tag Manager is already installed on your site
- You have your Deway App Key (available in your Deway dashboard)
Step 1: Add the Deway Base SDK Tag
This tag loads the Deway SDK and initializes it on every page.
Create the Base SDK Tag
- In GTM, go to Tags → New
- Name:
Deway – Base SDK - Tag type: Custom HTML
- HTML:
<!-- Deway Web SDK -->
<script src="https://unpkg.com/@deway-ai/web-sdk/dist/loader.umd.js"></script>
<script>
(function () {
function initDeway() {
if (!window.Deway || typeof window.Deway.init !== "function") return;
window.Deway.init({
appKey: "YOUR_DEWAY_APP_KEY" // replace with your actual appKey
});
}
initDeway();
})();
</script>
- Trigger:
Initialization – All Pages(orAll Pagesif Initialization is not available) - Click Save and publish your container
This ensures Deway is available on all pages.
Step 2: Push User Identity into the dataLayer
After a user logs in (or whenever you know who the user is), push their ID into the dataLayer from your application code:
// Example: after successful login
dataLayer.push({
event: "deway_user_identified",
userId: user.id // use your internal, stable user ID
});
Important: Use a stable internal ID (not an email) if possible for consistent user tracking.
Step 3: Create Data Layer Variable
Create a variable to capture the userId from the dataLayer.
- Go to Variables → New
- Name:
DLV – userId - Variable type: Data Layer Variable
- Data Layer Variable Name:
userId - Click Save
Step 4: Create the Deway Identify Tag
This tag listens for the deway_user_identified event and calls Deway.identify(userId).
Create the Identify Tag
- Go to Tags → New
- Name:
Deway – Identify User - Tag type: Custom HTML
- HTML:
<script>
(function () {
function doIdentify() {
var userId = "{{DLV - userId}}"; // dataLayer value
if (!userId) return;
if (window.Deway && typeof window.Deway.identify === "function") {
window.Deway.identify(userId);
} else {
// Retry if SDK isn't ready yet
setTimeout(doIdentify, 200);
}
}
doIdentify();
})();
</script>
- Trigger: New → Custom Event
- Event name:
deway_user_identified - Save the trigger and attach it to this tag
- Event name:
- Click Save and publish your container
Step 5: Verify Installation
Test with GTM Preview Mode
- Open your site with GTM Preview mode enabled
- Log in as a user (so the
dataLayer.pushfires) - In the GTM preview panel, confirm:
- The
deway_user_identifiedevent appears - The
Deway – Identify Usertag fires on that event
- The
- Check the browser console for any errors
What Happens Next
Once this is working, Deway will:
- ✅ Load on every page (base SDK tag)
- ✅ Identify logged-in users using the ID you send via dataLayer
- ✅ Begin monitoring user interactions and building your product knowledge graph
Complete Tag Configuration Summary
| Tag Name | Tag Type | Trigger | Purpose |
|---|---|---|---|
| Deway – Base SDK | Custom HTML | Initialization – All Pages | Loads and initializes Deway SDK |
| Deway – Identify User | Custom HTML | deway_user_identified | Associates user ID with session |
Troubleshooting
SDK not loading
Problem: Deway SDK doesn't initialize
- Check that the base SDK tag fires on the Initialization trigger
- Verify the CDN URL is accessible:
https://unpkg.com/@deway-ai/web-sdk/dist/loader.umd.js - Look for JavaScript errors in browser console
User identification not working
Problem: Deway.identify() is not being called
- Confirm the
deway_user_identifiedevent is being pushed to dataLayer - Check that the
DLV – userIdvariable is capturing the userId correctly - Verify the identify tag fires after the base SDK tag
Timing issues
Problem: Tags fire in wrong order
- Use
Initialization – All Pagestrigger for base SDK (notAll Pages) - The identify tag includes a retry mechanism with 200ms timeout
Advanced Configuration
Custom Configuration Options
You can pass additional configuration options in the base SDK tag:
<script>
window.Deway.init({
appKey: "YOUR_DEWAY_APP_KEY",
isDevelopment: false,
autoShowBubble: false
});
</script>
See SDK Configuration for all available options.
Conditional Loading
To load Deway only on specific pages, modify the base SDK tag trigger:
- Create a new trigger with conditions (e.g., URL contains
/app/) - Attach the new trigger to the
Deway – Base SDKtag
Next Steps
Getting Help
If you encounter issues with GTM installation:
- Check our GitHub
- Review GTM preview mode for debugging
- Contact our support team