Skip to main content

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

  1. In GTM, go to TagsNew
  2. Name: Deway – Base SDK
  3. Tag type: Custom HTML
  4. 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>
  1. Trigger: Initialization – All Pages (or All Pages if Initialization is not available)
  2. 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.

  1. Go to VariablesNew
  2. Name: DLV – userId
  3. Variable type: Data Layer Variable
  4. Data Layer Variable Name: userId
  5. 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

  1. Go to TagsNew
  2. Name: Deway – Identify User
  3. Tag type: Custom HTML
  4. 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>
  1. Trigger: New → Custom Event
    • Event name: deway_user_identified
    • Save the trigger and attach it to this tag
  2. Click Save and publish your container

Step 5: Verify Installation

Test with GTM Preview Mode

  1. Open your site with GTM Preview mode enabled
  2. Log in as a user (so the dataLayer.push fires)
  3. In the GTM preview panel, confirm:
    • The deway_user_identified event appears
    • The Deway – Identify User tag fires on that event
  4. 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 NameTag TypeTriggerPurpose
Deway – Base SDKCustom HTMLInitialization – All PagesLoads and initializes Deway SDK
Deway – Identify UserCustom HTMLdeway_user_identifiedAssociates 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_identified event is being pushed to dataLayer
  • Check that the DLV – userId variable 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 Pages trigger for base SDK (not All 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:

  1. Create a new trigger with conditions (e.g., URL contains /app/)
  2. Attach the new trigger to the Deway – Base SDK tag

Next Steps

Getting Help

If you encounter issues with GTM installation:

  • Check our GitHub
  • Review GTM preview mode for debugging
  • Contact our support team