-
Notifications
You must be signed in to change notification settings - Fork 1
/
event.go
43 lines (35 loc) · 875 Bytes
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Copyright (C) 2016 Acksin <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package gameasure
import (
"net/url"
)
// Event sends an event hit type.
type Event struct {
// Category is the event category
Category string `ga:"ec"`
// Action is the event action
Action string `ga:"ea"`
// Label is the event label
Label string `ga:"el"`
// Value event value
Value string `ga:"ev"`
}
// Event sends events to Google Analytics
func (g *GA) Event(e Event) error {
data := url.Values{}
data.Add("t", "event")
data.Add("ec", e.Category)
data.Add("ea", e.Action)
if e.Label != "" {
data.Add("el", e.Label)
}
if e.Value != "" {
data.Add("ev", e.Value)
}
return g.send(data)
}