If you are using Google Tag Manager (GTM) in your website, you can add D·engage Web SDK to your website by using GTM. For that, you have to create an application for your website on the Dengage Admin Panel.
In order to use D·engage Web SDK, you have to add an application for your website from the D·engage Admin Panel.

New Website

Push Notification
After saving the new website, you will be prompted with the SDK setup guide. You will see the HTML code you need to add to your website in a pop-up as shown below. This code will be used for the GTM tag configuration.

Code
You can access this information anytime by opening the More on the web application creation page and selecting Setup Guide.

Setup Guide
The HTML code you were given needs to be added as a tag in the Google Tag Manager.



To use Web Push, you must add the service worker file to your website. This cannot be done with GTM.
This file must be available at the following URL: https://yourwebsite.com/dengage-webpush-sw.js

Download Service Worker File
In order to collect website events and use that data to create behavioral segments in D·engage you have to determine the type of events and data that needs to collected. Once you have determined that, you will need to create a “Big Data” table in D·engage. Collected events will be stored in this table. Multiple tables can be defined depending on your specific need.
Any type of event can be collected. The content and the structure of the events are completely flexible and can be changed according to unique business requirements. You will just need to define a table for events.
Once defined, all you have to do is to send the event data to these tables. D·engage SDK has only two functions for sending events: sendDeviceEvent and sendCustomEvent. In most cases, you will only need the sendDeviceEvent function.
1. Using User Information
If the user logs in or you already have user information, this means you have contact_key for that user. You can set this contact_key to link the user with their browser. There are two functions for getting and setting contact_key.
2. Sending Device (Browser) Specific Events
You can use the sendDeviceEventfunction for sending events for the browser. These events are sent to a big data table defined in your D·engage account. The table must be linked to the master_device table. If you have set a contact_key for the browser, the collected events will automatically be associated with that user.
dengage(‘sendDeviceEvent’, tableName, dataObject[, callback]);
You can use these functions anywhere on your website code to send data. But if you want to use GTM to add these codes to your website. You can use multiple methods and this can be different for every website.
If you have existing events in the dataLayer, you can send those events to Dengage just by using GTM. You don’t have to do any code changes on your website.
If you have tags and triggers as shown below, you can use those triggers to create tags to send data to D·engage.

For every existing event sending tag , you have to create a corresponding tag that sends data to D·engage. You will be getting the required data from variables that are defined in the tag manager. You will be using two D·engage SDK functions for creating tags: sendDeviceEvent and setContactKey.
GTM variables can be used in tags with the double curly braces syntax. If you have a variable called “product id” you can use this value in your tags as {{ product id }}.
For a user login event, you must add a tag that sends the user id to the Dengage SDK. A user id is called a contact key in Dengage platform. For this action use the setContactKeyfunction.
Also, when a user logs out you can empty this value. This is optional.
Events other than login/logout can be sent using the sendDeviceEvent function.
For example if you have a transaction event and some variables related to this event like transactionId, transactionTotal, transactionTax, transactionShipping, you will be using a code as shown below:
Please note that the ‘user_events’ part is the table name that you have created as Big Data Table the D·engage Admin Panel.
This method requires code changes in your website. Use this method if you previously have no data or events added to the dataLayer or you don’t want to use existing data.
If you want to use the dataLayer to send data to D·engage, you have to push relevant data to the dataLayer where that event has happened. You can give these events a common name like dengage_event and add a trigger in GTM.
Use a code as shown below where necessary:
This added data will not be sent automatically to D·engage. In order to do that you have to add a tag in GTM. This tag requires two variables and a trigger.




Once you have created variables, you will need to create a trigger for D·engage events.



Result must be seen as shown below:

After that, test this workspace to make sure everything works and then publish.