Table of contents
With Google Analytics tracking, you can keep an eye on activity on your website and see the results of custom events that you set up with Google Tag Manager. For example, you can include custom events to track when a chat starts, when a chat ends, or when a new ticket is created.
1. Prerequisites
Before you set up Google Analytics tracking for SaleSmartly, you’ll need the following:
1.1 Google Analytics Account and Property
1.2 A SaleSmartly account
2. Retrieve the global site code
Note: If you have already set up a global site label for your website, you can skip this section.
2.1 Log in to your Google Analytics dashboard and navigate to Admin.

2.2. In the Admin page, click Setup Assistant under the Properties column. This will open a new panel.

2.3. In the panel, find the tab Installation and click on the > icon. This should open the options for setting up the data flow.

2.4. In Settings, select Web and a panel will appear.

2.5. In the panel, enter your website's URL and the desired data flow name. Then click Create Flow.

2.6. Next, the panel will redirect you to the stream details. From there, you can find your global site tag under Tag Description.

3. Sending events to Google Analytics
To send custom events to your Google Analytics account, you can use the gtag object loaded from the global site tag (gtag.js).
For example, we can use the SaleSmartly onSendMessage JS API to send a chat_started event to your Google Analytics account. Place this code in the of your web page.
<!-- Load SaleSmartly script -->
<script src="https://assets.salesmartly.com/js/project_xxxxxx.js"></script>
<!-- Track chat_started event -->
<script>
let isChatStarted = false;
ssq.push('onSendMessage', function(obj) {
if (!isChatStarted) {
isChatStarted = true;
gtag('event', 'chat_started'); // Send event to GA
}
});
</script>