Google Analytics
Last updated
Last updated
Integration with Google Analytics only works for the Universal Analytics version.
New properties are created in the GA4 version by default. Our requests will be ignored.
You need to create analytics with the switch turned on (as shown in the screenshot below)
Create a property on https://analytics.google.com/
Move into Tracking info -> Tracking code
Copy the code and paste it into the head of the mini-landing
To facilitate further work, it’s recommended to add properties to mini-landings using Google Tag Manager, but it’s not mandatory.
Next you need to find Tracking id in the Property settings
Copy the Tracking id, then open the project’s settings on Salebot and save the id in the Project Constants under the name of google_tracking_id:
To share the client id, you need to tick off Google Client ID(_ga) in the mini-landing’s settings. After the bot’s launch the variable _ga will appear.
During the function call for transferring data to Google Analytics, some parameters are being shared automatically, the info below is shown to get the general idea on how the function works.
For functions ga_pageview and ga_transaction_pageview the parameter “t”: “pageview” is transferred
For functions ga_event and ga_transaction_event the parameter “t”: “event” is transferred
For functions ga_transaction_pageview and ga_transaction_event the parameter “pa” with the value “purchase” is transferred additionally.
Also, when calling all functions, the parameter cid is transferred automatically - it’s the client id for analytics. If the user came into the bot from the mini-landing, as shown above, then the id gets automatically saved into the project variables, into the variable _ga
If the client card doesn't have this variable, then it’s generated automatically as a random line of numbers, but in that case it’s recommended to transfer the traffic source in the advanced settings (shown below - How to redefine the source)
If you need to set the traffic source for your event manually, then you can add any request type to it with the following parameters. The dictionary below isn’t independent - it’s used only when calling the functions mentioned in the Advanced parameters field.
'{ "cs":"#{utm_source}", "cm":"#{utm_medium}", "cn":"#{utm_campaign}", "ck":"#{utm_term}", "cc":"#{utm_content}"}'
Documentation on the parameters:
They are used in Google Analytics for certain events. You can configure the goals in GA, they are fixed when certain events happen (i.e. not all shared events have to be a goal necessarily).
You can find the events in the section Behaviour -> Events -> Top Events
You can configure goals for important workflow steps and use them for tracking conversions in between steps. Goals are set up in the section Conversions -> Goals
To transfer an event in GA, you need to, when moving to a different stage, call the function ga_event() with needed parameters in the calculator field.
ga_event (‘category’, ‘event action’, ‘label’, ‘event value’, ‘{“parameter name”: “value”, “parameter name 2”: “value 2”}’)
category - event category (mandatory parameter) event action - mandatory parameter label - event label event value gets transferred as integers and gets written down as the currency that’s set in the acquisition settings the dictionary with additional parameters; example: '{"ti":"#{order_id}", "tr":"25", "tcc":"#{promocode}"}'
ga_event('sale', 'list viewing’) ga_event('Salebot', 'Enter bot', '#{tag}', '100', '{"ti":"#{order_id}", "tr":"#{price}", "tcc":"#{promocode}"}') ga_event('Salebot', 'Enter bot', '#{tag}', '100') ga_event('Salebot', 'Enter bot', "", '20')
By transferring data on page viewership, you imitate a visit by the webpage user. To see a standard report of the pages, go to Behaviour -> Site Content
If you configure a goal for visiting pages, you can get a virtual workflow of following the bot’s branch without exiting Google Analytics.
An example of the configuration:
The advantage of this method is the visual representation of the workflow motion without having to leave Analytics.
The disadvantage, though, is the fact that you are essentially only transferring one parameter - the visit to a block. Additional data such as Label or Value, like in the Event requests, can’t be transferred like this.
To transfer data on viewing the page in GA when moving to a block, it’s essential to call the function ga_pageview() with needed parameters in the calculator field.
ga_pageview(‘URL page path’, ‘title’, ‘{“parameter name”: “value”, “parameter name 2”: “value 3”}’)
URL page path - the part of the URL that holds its path title - the title of the page/document a dictionary with additional parameters of this structure: ‘{“parameter name”: “value”, “parameter name 2”: “value 2”}’
ga_pageview('/start, 'Entry point') ga_pageview('/pay', ‘Sale’, '{"cd1": "High Scores"}')
For the transfer of additional parameters, refer to the documentation linked below. There you can find all possible parameters with detailed descriptions:
The E-commerce set up in the All Web Site Data tab
The E-commerce parameters need to be sent as the existing requests (pageview, event)
There are two functions for this purpose: ga_transaction_pageview and ga_transaction_event. More on them below.
Mandatory parameters are in bold:
ga_transaction_pageview('transaction id', 'total income’, 'URL page path', ‘title’, 'list of products’, 'dictionary of additional parameters’)
transaction id - the transaction’s unique id total income - the total income tied to the transaction URL page path - the part of the URL that holds its path title - the title of the page/document list of products - the array of products of this structure: '[["id", "name", "price", "amount"], ["id", "name", "price", "amount"]]' a dictionary with additional parameters of this structure: ‘{“parameter name”: “value”, “parameter name 2”: “value 2”}’
ga_transaction_pageview('#{order_id}', '2200', '/send', ‘Received’, '[["222", "Rate1", "1200", "1"], ["223", "AdditionalRate", "1000", "1"]]') ga_transaction_pageview('123', '100', '/pay', 'Payed', '', '{"cd": "High Scores", "cs":"#{utm_source}", "cm":"#{utm_medium}", "cn":"#{utm_campaign}"}' )
The array of products is as follows: array of arrays:
'[["product_id", "product name", "product price", "amount of products"], ["product_id", "product name", "product price", "amount of products"]]'
Each product must have 4 parameters, the whole array in single quotes (‘), the parameters inside - in double quotes (“)
Mandatory parameters are in bold:
ga_transaction_event('transaction id', 'transaction income’, 'event category', ‘event action’, 'event tag', 'event importance', 'list of products’, 'additional parameters’)
transaction id - the transaction’s unique id total income - the total income tied to the transaction event category, event action, event tag - mandatory parameters event importance - transferred in whole numbers and gets written down in the same currency as it is set in the viewing settings list of products - the array of products of this structure: '[["id", "name", "price", "amount"], ["id", "name", "price", "amount"]]' a dictionary with additional parameters of this structure: ‘{“parameter name”: “value”, “parameter name 2”: “value 2”}’
ga_transaction_event('1244', '121.2', 'category1', 'action', 'tag', '10', '[["11", "Product1", "1.2", "1"], ["22", "Product2", "120", "1"]]')
ga_transaction_event('1244', '1.2', 'category1', 'action', '', '', '[["11", "Product1", "1.20", "1"]]')
ga_transaction_event('1244', '121.2', 'category1', 'action', 'tag', '10', '[["11", "Product1", "1.2", "1"], ["22", "Product2", "120", "1"]]', '{"ta": "Google Store", "cs":"#{utm_source}", "cm":"#{utm_medium}", "cn":"#{utm_campaign}"}' )
The array of products is as follows: array of arrays:
'[["product_id", "product name", "product price", "amount of products"], ["product_id", "product name", "product price", "amount of products"]]'
Each product must have 4 parameters, the whole array in single quotes (‘), the parameters inside - in double quotes (“)