forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ga.d.ts
67 lines (59 loc) · 2.56 KB
/
ga.d.ts
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Type definitions for Google Analytics (Classic and Universal)
// Project: https://developers.google.com/analytics/devguides/collection/gajs/, https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference
// Definitions by: Ronnie Haakon Hegelund <http://ronniehegelund.blogspot.dk>, Pat Kujawa <http://patkujawa.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare class Tracker {
_trackPageview(): void;
_getName(): string;
_getAccount(): string;
_getVersion(): string;
_getVisitorCustomVar(index: number): string;
_setAccount(): string;
_setCustomVar(index: number, name: string, value: string, opt_scope?: number): boolean;
_setSampleRate(newRate: string): void;
_setSessionCookieTimeout(cookieTimeoutMillis: number): void;
_setSiteSpeedSampleRate(sampleRate: number): void;
_setVisitorCookieTimeout(milliseconds: number): void;
_trackPageLoadTime(): void;
}
interface GoogleAnalyticsCode {
push(commandArray: string[]): void;
push(func: Function): void;
}
interface GoogleAnalyticsTracker {
_getTracker(account: string): Tracker;
_createTracker(opt_account: string, opt_name?: string): Tracker;
_getTrackerByName(opt_name?: string): Tracker;
_anonymizeIp(): void;
}
interface GoogleAnalytics {
type: string;
src: string;
async: boolean;
}
declare module UniversalAnalytics {
// https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference
interface ga {
l: number;
q: any[];
(command: string, poly: string, opt_poly?: {}): UniversalAnalytics.Tracker;
(command: string, trackingId: string, auto: string, opt_configObject?: {}): UniversalAnalytics.Tracker;
(command: string, hitDetails: {}): void;
create(trackingId: string, opt_configObject?: {}): UniversalAnalytics.Tracker;
create(trackingId: string, auto: string, opt_configObject?: {}): UniversalAnalytics.Tracker;
getAll(): UniversalAnalytics.Tracker[];
getByName(name: string): UniversalAnalytics.Tracker;
}
interface Tracker {
get<T>(fieldName: string): T;
send(hitType: string, opt_fieldObject?: {}): void;
set(fieldName: string, value: string): void;
set(fieldName: string, value: {}): void;
set(fieldName: string, value: number): void;
set(fieldName: string, value: boolean): void;
}
}
declare var gaClassic: GoogleAnalytics;
declare var ga: UniversalAnalytics.ga;
declare var _gaq: GoogleAnalyticsCode;
declare var _gat: GoogleAnalyticsTracker;