Google Analytics tracking
Use Google Analytics for tracking bot statistic.

Usage

Track events can be more usefull for bot
1
// Track an Event (all values optional)
2
GoogleAnalytics.event({
3
ua_key: "UA-XXXXXX-1",
4
category: 'refferal',
5
action: 'attracted by',
6
label: user.id,
7
value: 1
8
})
Copied!
1
// Track exceptions (all values optional)
2
GoogleAnalytics.exception({
3
ua_key: "UA-XXXXXX-1",
4
description: 'No money',
5
fatal: false
6
})
Copied!
1
// Track timing (all values optional, but should include time)
2
// time in milliseconds
3
GoogleAnalytics.timing({
4
ua_key: "UA-XXXXXX-1",
5
category: 'downloading',
6
variable: 'external-api',
7
label: 'coinpayments',
8
time: 50
9
})
Copied!
1
// Track a Pageview (all values optional)
2
GoogleAnalytics.pageview({
3
ua_key: "UA-XXXXXX-1",
4
path: '/vip-area',
5
hostname: 'bots.business',
6
title: 'Vip Area'
7
})
Copied!
1
// Track social activity (all values REQUIRED)
2
GoogleAnalytics.social({
3
ua_key: "UA-XXXXXX-1",
4
action: 'like',
5
network: 'facebook',
6
target: '/article_1'
7
})
Copied!

Track transactions

1
// Track transaction
2
// (transaction_id REQUIRED)
3
GoogleAnalytics.transaction({
4
ua_key: "UA-XXXXXX-1",
5
transaction_id: 12345,
6
affiliation: 'clothing',
7
revenue: 17.98,
8
shipping: 2.00,
9
tax: 2.50,
10
currency: 'EUR'
11
})
Copied!
1
// Track transaction item
2
// (matching transaction_id and item name REQUIRED)
3
GoogleAnalytics.transaction_item({
4
ua_key: "UA-XXXXXX-1",
5
transaction_id: 12345,
6
name: 'Shirt',
7
price: 8.99,
8
quantity: 2,
9
code: 'afhcka1230',
10
variation: 'red',
11
currency: 'EUR'
12
})
Copied!

"Global" Options

Any of the options on the parameters list (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters) that are accepted on ALL hit types can be set as options on any of the hits.
1
GoogleAnalytics.pageview({ path: '/video/1235', user_id: user.id })
Copied!
User id is a global option in the example above.
The complete list at this time:
1
anonymize_ip,
2
queue_time,
3
data_source,
4
cache_buster,
5
user_id,
6
user_ip,
7
user_agent,
8
referrer,
9
campaign_name,
10
campaign_source,
11
campaign_medium,
12
campaign_keyword,
13
campaign_content,
14
campaign_id,
15
adwords_id,
16
display_ads_id,
17
screen_resolution,
18
viewport_size,
19
screen_colors,
20
user_language,
21
java_enabled,
22
flash_version,
23
document_location,
24
document_encoding,
25
document_hostname,
26
document_path,
27
document_title,
28
link_id,
29
application_name,
30
application_version,
31
application_id,
32
application_installer_id,
33
experiment_id,
34
experiment_variant,
35
product_action,
36
product_action_list,
37
promotion_action,
38
geographical_id
Copied!
Boolean options like anonymize_ip will be converted from true/false into 1/0 as per the tracking API docs.

Non-Interactive Hit

1
# Track a Non-Interactive Hit
2
GoogleAnalytics.event({ category: 'webhook', action: 'send', non_interactive: true })
Copied!
Non-Interactive events are useful for tracking things like emails sent, or other events that are not directly the result of a user's interaction.
The option non_interactive is accepted for all methods on tracker.

Session Control

1
// start a session
2
GoogleAnalytics.pageview({ path: '/blog', start_session: true })
3
4
// end a session
5
GoogleAnalytics.pageview({ path: '/blog', end_session: true })
Copied!
Other options are acceptable to start and end a session: session_start, session_end, and stop_session.

Content Experiment

1
// Tracking an Experiment
2
// useful for tracking A/B or Multivariate testing
3
GoogleAnalytics.pageview({
4
path: '/blog',
5
experiment_id: 'a7a8d91df',
6
experiment_variant: 'a'
7
})
Copied!