Menu

How to set up SaleSmartly for Google Analytics tracking

With Google Analytics tracking, you can keep a close eye on your site’s activity and see the results of custom events you set up using Google Tracking Code Manager. For example, you can include custom events to track when a chat starts, when a chat ends, or when a new work order is created.

Prerequisites

Before setting up Google Analytics tracking for SaleSmartly, you will need the following.

  1. Google Analytics accounts and resources
  2. A SaleSmartly account

Retrieve global site codes

Note: If you have set up global site tags for your site, you can skip this section.

1 – Log in to your Google Analytics dashboard and navigate to Admin.

2 – In the Administration page, click Setup Assistant under the Properties column. This will open a new panel.

3 – In the panel, find the tab installation and click the > icon. This should open the option to set the data stream.

4 – In Settings, select Web and a panel will appear.

5 – In the panel, enter the URL of your website and the name of the desired data stream. Then click Create Stream.

6 – Next, the panel will redirect you to the stream details. From there, you can find your global site tag under the tag description.

Send events to Google Analytics

To send custom events to your Google Analytics account, you can use the gtag object loaded from the global site code (gtag.js).

For example, we can use the SaleSmartly onSendMessage JS API to send the chat_started event to your Google Analytics account. Place this code in the of the page.

// 引用您的插件链接
<script src="https://assets.salesmartly.com/js/project_xxxxxx.js"></script> 
// 给google上报chat_started事件 
<script type="text/javascript"> 
  var isChatStarted = false; 
  ssq.push('onSendMessage', function(obj) {    
    if (!isChatStarted) {       
      isChatStarted = true;      
      gtag('event', 'chat_started');    
    } 
  }); 
</script> 


Last modified: 2023-03-23Powered by