react-native-google-analytics-bridge
Advanced tools
Comparing version 6.0.0-rc6 to 6.0.0-rc7
/** | ||
* Google analytics settings shared across all GoogleAnalyticsTracker instances. | ||
* @typicalname GoogleAnalyticsSettings | ||
*/ | ||
export default class GoogleAnalyticsSettings { | ||
declare class GoogleAnalyticsSettings { | ||
/** | ||
* Sets if OptOut is active and disables Google Analytics | ||
* This has to be set each time the App starts | ||
* @param {Boolean} enabled | ||
* @param {boolean} enabled | ||
*/ | ||
@@ -15,3 +15,3 @@ static setOptOut(enabled: boolean): void; | ||
* are sent to your tracker. | ||
* @param {Number} intervalInSeconds | ||
* @param {number} intervalInSeconds | ||
*/ | ||
@@ -22,5 +22,6 @@ static setDispatchInterval(intervalInSeconds: number): void; | ||
* If dry run is enabled, no analytics data will be sent to your tracker. | ||
* @param {Boolean} enabled | ||
* @param {boolean} enabled | ||
*/ | ||
static setDryRun(enabled: boolean): void; | ||
} | ||
export default GoogleAnalyticsSettings; |
import { AnalyticsSettings } from "./NativeBridges"; | ||
/** | ||
* Google analytics settings shared across all GoogleAnalyticsTracker instances. | ||
* @typicalname GoogleAnalyticsSettings | ||
*/ | ||
export default class GoogleAnalyticsSettings { | ||
class GoogleAnalyticsSettings { | ||
/** | ||
* Sets if OptOut is active and disables Google Analytics | ||
* This has to be set each time the App starts | ||
* @param {Boolean} enabled | ||
* @param {boolean} enabled | ||
*/ | ||
@@ -18,3 +18,3 @@ static setOptOut(enabled) { | ||
* are sent to your tracker. | ||
* @param {Number} intervalInSeconds | ||
* @param {number} intervalInSeconds | ||
*/ | ||
@@ -27,3 +27,3 @@ static setDispatchInterval(intervalInSeconds) { | ||
* If dry run is enabled, no analytics data will be sent to your tracker. | ||
* @param {Boolean} enabled | ||
* @param {boolean} enabled | ||
*/ | ||
@@ -34,1 +34,2 @@ static setDryRun(enabled) { | ||
} | ||
export default GoogleAnalyticsSettings; |
import { HitPayload } from "./HitPayload"; | ||
import { CustomDimensionsByField, CustomDimensionsByIndex, CustomDimensionsFieldIndexMap } from "./Custom"; | ||
import { CustomDimensionsFieldIndexMap } from "./Custom"; | ||
/** | ||
* Used to bridge tracker data to native Google analytics. | ||
* Saves necessary tracker (specific) data to format data as native part of Google analytics expect. | ||
* @typicalname tracker | ||
*/ | ||
export default class GoogleAnalyticsTracker { | ||
declare class GoogleAnalyticsTracker { | ||
id: string; | ||
@@ -12,4 +11,9 @@ customDimensionsFieldsIndexMap: CustomDimensionsFieldIndexMap; | ||
* Save all tracker related data that is needed to call native methods with proper data. | ||
* @param {String} trackerId | ||
* @param {string} trackerId Your tracker id, something like: UA-12345-1 | ||
* @param {{fieldName: fieldIndex}} customDimensionsFieldsIndexMap Custom dimensions field/index pairs | ||
* @example | ||
* ```js | ||
* import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge'; | ||
* let tracker = new GoogleAnalyticsTracker('UA-12345-1'); | ||
* ``` | ||
*/ | ||
@@ -24,9 +28,17 @@ constructor(trackerId: string, customDimensionsFieldsIndexMap?: CustomDimensionsFieldIndexMap); | ||
* not dimension field names. | ||
* @param {CustomDimensionsByIndex} customDimensions | ||
* @returns {CustomDimensionsByField} | ||
* @ignore | ||
* @param {{fieldName: value}} customDimensions | ||
* @returns {{fieldIndex: value}} | ||
*/ | ||
transformCustomDimensionsFieldsToIndexes(customDimensions: CustomDimensionsByIndex): CustomDimensionsByField; | ||
private transformCustomDimensionsFieldsToIndexes(customDimensions); | ||
/** | ||
* Track the current screen/view | ||
* @param {String} screenName The name of the current screen | ||
* @example | ||
* ```js | ||
* tracker.trackScreenView('Home') | ||
* ``` | ||
* Track the current screen/view. Calling this will also set the "current view" for other calls. | ||
* So events tracked will be tagged as having occured on the current view, `Home` in this example. | ||
* This means it is important to track navigation, especially if events can fire on different views. | ||
* @param {string} screenName (Required) The name of the current screen | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
*/ | ||
@@ -36,5 +48,7 @@ trackScreenView(screenName: string, payload?: HitPayload): void; | ||
* Track an event that has occured | ||
* @param {String} category The event category | ||
* @param {String} action The event action | ||
* @param {OptionalValue} optionalValues An object containing optional label and value | ||
* @param {string} category (Required) The event category | ||
* @param {string} action (Required) The event action | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
* @param {string} label (Optional) An optional event label | ||
* @param {number} value (Optional) An optional event value | ||
*/ | ||
@@ -44,11 +58,14 @@ trackEvent(category: string, action: string, payload?: HitPayload, label?: string, value?: number): void; | ||
* Track an event that has occured | ||
* @param {String} category The event category | ||
* @param {Number} value The timing measurement in milliseconds | ||
* @param {OptionalTimingValue} optionalValues An object containing optional name and label | ||
* @param {string} category (Required) The event category | ||
* @param {number} interval (Required) The timing measurement in milliseconds | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
* @param {string} name (Required) The timing name | ||
* @param {string} label (Optional) An optional timing label | ||
*/ | ||
trackTiming(category: string, value: number, payload?: HitPayload, name?: string, label?: string): void; | ||
trackTiming(category: string, interval: number, payload?: HitPayload, name?: string, label?: string): void; | ||
/** | ||
* Track an exception | ||
* @param {String} error The description of the error | ||
* @param {Boolean} fatal A value indiciating if the error was fatal, defaults to false | ||
* @param {string} error (Required) The description of the error | ||
* @param {boolean} fatal (Optional) A value indiciating if the error was fatal, defaults to false | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
*/ | ||
@@ -58,5 +75,6 @@ trackException(error: string, fatal?: boolean, payload?: HitPayload): void; | ||
* Track a social interaction, Facebook, Twitter, etc. | ||
* @param {String} network | ||
* @param {String} action | ||
* @param {String} targetUrl | ||
* @param {string} network | ||
* @param {string} action | ||
* @param {string} targetUrl | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
*/ | ||
@@ -66,3 +84,3 @@ trackSocialInteraction(network: string, action: string, targetUrl: string, payload: HitPayload): void; | ||
* Sets the current userId for tracking. | ||
* @param {String} userId The current userId | ||
* @param {string} userId The current userId | ||
*/ | ||
@@ -72,3 +90,3 @@ setUser(userId: string): void; | ||
* Sets the current clientId for tracking. | ||
* @param {String} clientId The current userId | ||
* @param {string} clientId The current userId | ||
*/ | ||
@@ -78,9 +96,9 @@ setClient(clientId: string): void; | ||
* Sets if IDFA (identifier for advertisers) collection should be enabled | ||
* @param {Boolean} enabled Defaults to true | ||
* @param {boolean} enabled (Optional) Defaults to true | ||
*/ | ||
allowIDFA(enabled: boolean): void; | ||
allowIDFA(enabled?: boolean): void; | ||
/** | ||
* Sets the trackers appName | ||
* The Bundle name is used by default | ||
* @param {String} appName | ||
* @param {string} appName (Required) | ||
*/ | ||
@@ -90,3 +108,3 @@ setAppName(appName: string): void; | ||
* Sets the trackers appVersion | ||
* @param {String} appVersion | ||
* @param {string} appVersion (Required) | ||
*/ | ||
@@ -97,3 +115,3 @@ setAppVersion(appVersion: string): void; | ||
* If enabled the last octet of the IP address will be removed | ||
* @param {Boolean} enabled | ||
* @param {boolean} enabled (Required) | ||
*/ | ||
@@ -103,3 +121,3 @@ setAnonymizeIp(enabled: boolean): void; | ||
* Sets tracker sampling rate. | ||
* @param {Float} sampleRatio Percentage 0 - 100 | ||
* @param {number} sampleRatio (Required) Percentage 0 - 100 | ||
*/ | ||
@@ -109,3 +127,3 @@ setSamplingRate(sampleRatio: number): void; | ||
* Sets the currency for tracking. | ||
* @param {String} currencyCode The currency ISO 4217 code | ||
* @param {string} currencyCode (Required) The currency ISO 4217 code | ||
*/ | ||
@@ -117,5 +135,6 @@ setCurrency(currencyCode: string): void; | ||
* If you are using multiple trackers on iOS, this will enable & disable on all trackers. | ||
* @param {Boolean} enabled | ||
* @param {boolean} enabled | ||
*/ | ||
setTrackUncaughtExceptions(enabled: boolean): void; | ||
} | ||
export default GoogleAnalyticsTracker; |
import { AnalyticsBridge } from "./NativeBridges"; | ||
/** | ||
* Custom dimensions accept only strings and numbers. | ||
* @ignore | ||
* @param customDimensionVal | ||
@@ -12,10 +13,14 @@ * @returns {boolean} | ||
/** | ||
* Used to bridge tracker data to native Google analytics. | ||
* Saves necessary tracker (specific) data to format data as native part of Google analytics expect. | ||
* @typicalname tracker | ||
*/ | ||
export default class GoogleAnalyticsTracker { | ||
class GoogleAnalyticsTracker { | ||
/** | ||
* Save all tracker related data that is needed to call native methods with proper data. | ||
* @param {String} trackerId | ||
* @param {string} trackerId Your tracker id, something like: UA-12345-1 | ||
* @param {{fieldName: fieldIndex}} customDimensionsFieldsIndexMap Custom dimensions field/index pairs | ||
* @example | ||
* ```js | ||
* import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge'; | ||
* let tracker = new GoogleAnalyticsTracker('UA-12345-1'); | ||
* ``` | ||
*/ | ||
@@ -33,4 +38,5 @@ constructor(trackerId, customDimensionsFieldsIndexMap) { | ||
* not dimension field names. | ||
* @param {CustomDimensionsByIndex} customDimensions | ||
* @returns {CustomDimensionsByField} | ||
* @ignore | ||
* @param {{fieldName: value}} customDimensions | ||
* @returns {{fieldIndex: value}} | ||
*/ | ||
@@ -50,4 +56,11 @@ transformCustomDimensionsFieldsToIndexes(customDimensions) { | ||
/** | ||
* Track the current screen/view | ||
* @param {String} screenName The name of the current screen | ||
* @example | ||
* ```js | ||
* tracker.trackScreenView('Home') | ||
* ``` | ||
* Track the current screen/view. Calling this will also set the "current view" for other calls. | ||
* So events tracked will be tagged as having occured on the current view, `Home` in this example. | ||
* This means it is important to track navigation, especially if events can fire on different views. | ||
* @param {string} screenName (Required) The name of the current screen | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
*/ | ||
@@ -59,7 +72,12 @@ trackScreenView(screenName, payload = null) { | ||
* Track an event that has occured | ||
* @param {String} category The event category | ||
* @param {String} action The event action | ||
* @param {OptionalValue} optionalValues An object containing optional label and value | ||
* @param {string} category (Required) The event category | ||
* @param {string} action (Required) The event action | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
* @param {string} label (Optional) An optional event label | ||
* @param {number} value (Optional) An optional event value | ||
*/ | ||
trackEvent(category, action, payload = null, label = null, value = null) { | ||
let customDimensions = payload.customDimensions; | ||
let transformed = this.transformCustomDimensionsFieldsToIndexes(customDimensions); | ||
payload.customDimensions = transformed; | ||
AnalyticsBridge.trackEvent(this.id, category, action, label, value, payload); | ||
@@ -69,13 +87,16 @@ } | ||
* Track an event that has occured | ||
* @param {String} category The event category | ||
* @param {Number} value The timing measurement in milliseconds | ||
* @param {OptionalTimingValue} optionalValues An object containing optional name and label | ||
* @param {string} category (Required) The event category | ||
* @param {number} interval (Required) The timing measurement in milliseconds | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
* @param {string} name (Required) The timing name | ||
* @param {string} label (Optional) An optional timing label | ||
*/ | ||
trackTiming(category, value, payload = null, name = null, label = null) { | ||
AnalyticsBridge.trackTiming(this.id, category, value, name, label, payload); | ||
trackTiming(category, interval, payload = null, name = null, label = null) { | ||
AnalyticsBridge.trackTiming(this.id, category, interval, name, label, payload); | ||
} | ||
/** | ||
* Track an exception | ||
* @param {String} error The description of the error | ||
* @param {Boolean} fatal A value indiciating if the error was fatal, defaults to false | ||
* @param {string} error (Required) The description of the error | ||
* @param {boolean} fatal (Optional) A value indiciating if the error was fatal, defaults to false | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
*/ | ||
@@ -87,5 +108,6 @@ trackException(error, fatal = false, payload = null) { | ||
* Track a social interaction, Facebook, Twitter, etc. | ||
* @param {String} network | ||
* @param {String} action | ||
* @param {String} targetUrl | ||
* @param {string} network | ||
* @param {string} action | ||
* @param {string} targetUrl | ||
* @param {Object} payload (Optional) An object containing the hit payload | ||
*/ | ||
@@ -97,3 +119,3 @@ trackSocialInteraction(network, action, targetUrl, payload) { | ||
* Sets the current userId for tracking. | ||
* @param {String} userId The current userId | ||
* @param {string} userId The current userId | ||
*/ | ||
@@ -105,3 +127,3 @@ setUser(userId) { | ||
* Sets the current clientId for tracking. | ||
* @param {String} clientId The current userId | ||
* @param {string} clientId The current userId | ||
*/ | ||
@@ -113,5 +135,5 @@ setClient(clientId) { | ||
* Sets if IDFA (identifier for advertisers) collection should be enabled | ||
* @param {Boolean} enabled Defaults to true | ||
* @param {boolean} enabled (Optional) Defaults to true | ||
*/ | ||
allowIDFA(enabled) { | ||
allowIDFA(enabled = true) { | ||
AnalyticsBridge.allowIDFA(this.id, enabled); | ||
@@ -122,3 +144,3 @@ } | ||
* The Bundle name is used by default | ||
* @param {String} appName | ||
* @param {string} appName (Required) | ||
*/ | ||
@@ -130,3 +152,3 @@ setAppName(appName) { | ||
* Sets the trackers appVersion | ||
* @param {String} appVersion | ||
* @param {string} appVersion (Required) | ||
*/ | ||
@@ -139,3 +161,3 @@ setAppVersion(appVersion) { | ||
* If enabled the last octet of the IP address will be removed | ||
* @param {Boolean} enabled | ||
* @param {boolean} enabled (Required) | ||
*/ | ||
@@ -147,3 +169,3 @@ setAnonymizeIp(enabled) { | ||
* Sets tracker sampling rate. | ||
* @param {Float} sampleRatio Percentage 0 - 100 | ||
* @param {number} sampleRatio (Required) Percentage 0 - 100 | ||
*/ | ||
@@ -155,3 +177,3 @@ setSamplingRate(sampleRatio) { | ||
* Sets the currency for tracking. | ||
* @param {String} currencyCode The currency ISO 4217 code | ||
* @param {string} currencyCode (Required) The currency ISO 4217 code | ||
*/ | ||
@@ -165,3 +187,3 @@ setCurrency(currencyCode) { | ||
* If you are using multiple trackers on iOS, this will enable & disable on all trackers. | ||
* @param {Boolean} enabled | ||
* @param {boolean} enabled | ||
*/ | ||
@@ -172,1 +194,2 @@ setTrackUncaughtExceptions(enabled) { | ||
} | ||
export default GoogleAnalyticsTracker; |
import DataLayerEvent from "./DataLayerEvent"; | ||
export default class GoogleTagManager { | ||
/** | ||
* @typicalname GoogleTagManager | ||
*/ | ||
declare class GoogleTagManager { | ||
/** | ||
* Call once to open the container for all subsequent static calls. | ||
* @param {String} containerId | ||
* @param {string} containerId | ||
* @returns {Promise<boolean>} | ||
@@ -11,3 +14,3 @@ */ | ||
* Retrieves a boolean value with the given key from the opened container. | ||
* @param {String} key | ||
* @param {string} key | ||
* @returns {Promise<boolean>} | ||
@@ -18,4 +21,4 @@ */ | ||
* Retrieves a string with the given key from the opened container. | ||
* @param {String} key | ||
* @returns {String} | ||
* @param {string} key | ||
* @returns {Promise<string>} | ||
*/ | ||
@@ -25,3 +28,3 @@ static stringForKey(key: string): Promise<string>; | ||
* Retrieves a number with the given key from the opened container. | ||
* @param {String} key | ||
* @param {string} key | ||
* @returns {Promise<number>} | ||
@@ -38,1 +41,2 @@ */ | ||
} | ||
export default GoogleTagManager; |
import { TagManagerBridge } from "./NativeBridges"; | ||
export default class GoogleTagManager { | ||
/** | ||
* @typicalname GoogleTagManager | ||
*/ | ||
class GoogleTagManager { | ||
/** | ||
* Call once to open the container for all subsequent static calls. | ||
* @param {String} containerId | ||
* @param {string} containerId | ||
* @returns {Promise<boolean>} | ||
@@ -13,3 +16,3 @@ */ | ||
* Retrieves a boolean value with the given key from the opened container. | ||
* @param {String} key | ||
* @param {string} key | ||
* @returns {Promise<boolean>} | ||
@@ -22,4 +25,4 @@ */ | ||
* Retrieves a string with the given key from the opened container. | ||
* @param {String} key | ||
* @returns {String} | ||
* @param {string} key | ||
* @returns {Promise<string>} | ||
*/ | ||
@@ -31,3 +34,3 @@ static stringForKey(key) { | ||
* Retrieves a number with the given key from the opened container. | ||
* @param {String} key | ||
* @param {string} key | ||
* @returns {Promise<number>} | ||
@@ -48,1 +51,2 @@ */ | ||
} | ||
export default GoogleTagManager; |
{ | ||
"name": "react-native-google-analytics-bridge", | ||
"version": "6.0.0-rc6", | ||
"version": "6.0.0-rc7", | ||
"description": | ||
@@ -9,3 +9,4 @@ "React Native bridge for using native Google Analytics libraries on iOS and Android", | ||
"scripts": { | ||
"test": "echo \"Error: no test yet!\" && exit 0" | ||
"test": "echo \"Error: no test yet!\" && exit 0", | ||
"docs": "jsdoc2md --template docs/README.hbs --files dist/*.js > README.md" | ||
}, | ||
@@ -53,2 +54,3 @@ "repository": { | ||
"@types/react-native": "^0.48.4", | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"prettier": "^1.6.1", | ||
@@ -55,0 +57,0 @@ "react": "16.0.0-alpha.12", |
562
README.md
@@ -78,434 +78,342 @@ GoogleAnalyticsBridge [![npm version](https://img.shields.io/npm/v/react-native-google-analytics-bridge.svg)](https://www.npmjs.com/package/react-native-google-analytics-bridge) [![Build Status](https://travis-ci.org/idehub/react-native-google-analytics-bridge.svg?branch=master)](https://travis-ci.org/idehub/react-native-google-analytics-bridge) | ||
## JavaScript API | ||
* [GoogleAnalyticsTracker](#googleanalyticstracker-api) | ||
* [GoogleAnalyticsSettings](#googleanalyticssettings-api) | ||
* [GoogleTagManager](#googletagmanager-api) | ||
## Classes | ||
## GoogleAnalyticsTracker API | ||
<dl> | ||
<dt><a href="#GoogleAnalyticsSettings">GoogleAnalyticsSettings</a></dt> | ||
<dd></dd> | ||
<dt><a href="#GoogleAnalyticsTracker">GoogleAnalyticsTracker</a></dt> | ||
<dd></dd> | ||
<dt><a href="#GoogleTagManager">GoogleTagManager</a></dt> | ||
<dd></dd> | ||
</dl> | ||
### new GoogleAnalyticsTracker(trackerId, customDimensionsFieldsIndexMap = {}) | ||
* **trackerId (required):** String, your tracker id, something like: UA-12345-1 | ||
* **customDimensionsFieldsIndexMap (optional):** {{fieldName: fieldIndex}} Custom dimensions field/index pairs | ||
<a name="GoogleAnalyticsSettings"></a> | ||
```javascript | ||
import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge'; | ||
let tracker = new GoogleAnalyticsTracker('UA-12345-1'); | ||
``` | ||
## GoogleAnalyticsSettings | ||
**Kind**: global class | ||
Google Analytics expects dimensions to be tracked by indices, and not field names. | ||
To simplify this, you can construct a tracker with a customDimensionsFieldsIndexMap. With this, you can map field names to indices, e.g: | ||
* [GoogleAnalyticsSettings](#GoogleAnalyticsSettings) | ||
* [.setOptOut(enabled)](#GoogleAnalyticsSettings.setOptOut) | ||
* [.setDispatchInterval(intervalInSeconds)](#GoogleAnalyticsSettings.setDispatchInterval) | ||
* [.setDryRun(enabled)](#GoogleAnalyticsSettings.setDryRun) | ||
```javascript | ||
let tracker2 = new GoogleAnalyticsTracker('UA-12345-3', { test: 1 }); | ||
tracker2.trackScreenViewWithCustomDimensionValues('Home', { test: 'Beta' }); | ||
``` | ||
<a name="GoogleAnalyticsSettings.setOptOut"></a> | ||
Here the underlying logic will transform the custom dimension, so what ends up being sent to GA is `{ 1: 'Beta' }`. | ||
This should make it easier to use custom dimensions. If you do not provide a customDimensionsFieldsIndexMap, the custom dimensions are passed through untouched. | ||
### GoogleAnalyticsSettings.setOptOut(enabled) | ||
Sets if OptOut is active and disables Google Analytics | ||
This has to be set each time the App starts | ||
### trackScreenView(screenName) | ||
**Kind**: static method of [<code>GoogleAnalyticsSettings</code>](#GoogleAnalyticsSettings) | ||
* **screenName (required):** String, name of current screen | ||
| Param | Type | | ||
| --- | --- | | ||
| enabled | <code>boolean</code> | | ||
**Important**: Calling this will also set the "current view" for other calls. So events tracked will be tagged as having occured on the current view, `Home` in this example. This means it is important to track navigation, especially if events can fire on different views. | ||
<a name="GoogleAnalyticsSettings.setDispatchInterval"></a> | ||
See the [Google Analytics docs](https://developers.google.com/analytics/devguides/collection/ios/v3/screens) for more info | ||
### GoogleAnalyticsSettings.setDispatchInterval(intervalInSeconds) | ||
Sets the trackers dispatch interval | ||
This will influence how often batches of events, screen views, etc | ||
are sent to your tracker. | ||
```javascript | ||
tracker.trackScreenView('Home') | ||
``` | ||
**Kind**: static method of [<code>GoogleAnalyticsSettings</code>](#GoogleAnalyticsSettings) | ||
### trackEvent(category, action, optionalValues) | ||
| Param | Type | | ||
| --- | --- | | ||
| intervalInSeconds | <code>number</code> | | ||
* **category (required):** String, category of event | ||
* **action (required):** String, name of action | ||
* **optionalValues:** Object | ||
* **label:** String | ||
* **value:** Number | ||
<a name="GoogleAnalyticsSettings.setDryRun"></a> | ||
See the [Google Analytics docs](https://developers.google.com/analytics/devguides/collection/ios/v3/events) for more info. | ||
### GoogleAnalyticsSettings.setDryRun(enabled) | ||
Sets if the tracker should have dry run enabled. | ||
If dry run is enabled, no analytics data will be sent to your tracker. | ||
```javascript | ||
tracker.trackEvent('testcategory', 'testaction'); | ||
// or | ||
tracker.trackEvent('testcategory', 'testaction', {label: 'v1.0.3', value: 22}); | ||
``` | ||
**Kind**: static method of [<code>GoogleAnalyticsSettings</code>](#GoogleAnalyticsSettings) | ||
### trackTiming(category, value, optionalValues) | ||
| Param | Type | | ||
| --- | --- | | ||
| enabled | <code>boolean</code> | | ||
* **category (required):** String, category of the timed event | ||
* **value (required):** Number, the timing measurement in milliseconds | ||
* **optionalValues:** Object | ||
* **name (required):** String, the name of the timed event | ||
* **label:** String, the label of the timed event | ||
<a name="GoogleAnalyticsTracker"></a> | ||
See the [Google Analytics docs](https://developers.google.com/analytics/devguides/collection/ios/v3/usertimings) for more info. | ||
## GoogleAnalyticsTracker | ||
**Kind**: global class | ||
```javascript | ||
tracker.trackTiming('testcategory', 13000, {name: 'LoadList'}); // name option is required | ||
// or | ||
tracker.trackTiming('testcategory', 13000, {name: 'loadList', label: 'v1.0.3'}); | ||
``` | ||
* [GoogleAnalyticsTracker](#GoogleAnalyticsTracker) | ||
* [new GoogleAnalyticsTracker(trackerId, customDimensionsFieldsIndexMap)](#new_GoogleAnalyticsTracker_new) | ||
* [.trackScreenView(screenName, payload)](#GoogleAnalyticsTracker+trackScreenView) | ||
* [.trackEvent(category, action, payload, label, value)](#GoogleAnalyticsTracker+trackEvent) | ||
* [.trackTiming(category, interval, payload, name, label)](#GoogleAnalyticsTracker+trackTiming) | ||
* [.trackException(error, fatal, payload)](#GoogleAnalyticsTracker+trackException) | ||
* [.trackSocialInteraction(network, action, targetUrl, payload)](#GoogleAnalyticsTracker+trackSocialInteraction) | ||
* [.setUser(userId)](#GoogleAnalyticsTracker+setUser) | ||
* [.setClient(clientId)](#GoogleAnalyticsTracker+setClient) | ||
* [.allowIDFA(enabled)](#GoogleAnalyticsTracker+allowIDFA) | ||
* [.setAppName(appName)](#GoogleAnalyticsTracker+setAppName) | ||
* [.setAppVersion(appVersion)](#GoogleAnalyticsTracker+setAppVersion) | ||
* [.setAnonymizeIp(enabled)](#GoogleAnalyticsTracker+setAnonymizeIp) | ||
* [.setSamplingRate(sampleRatio)](#GoogleAnalyticsTracker+setSamplingRate) | ||
* [.setCurrency(currencyCode)](#GoogleAnalyticsTracker+setCurrency) | ||
* [.setTrackUncaughtExceptions(enabled)](#GoogleAnalyticsTracker+setTrackUncaughtExceptions) | ||
### trackPurchaseEvent(product, transaction, eventCategory, eventAction) | ||
<a name="new_GoogleAnalyticsTracker_new"></a> | ||
* **product (required):** Object | ||
* **id (required):** String | ||
* **name (required):** String | ||
* **category (optional):** String | ||
* **brand (optional):** String | ||
* **variant (optional):** String | ||
* **price (optional):** Number | ||
* **quantity (optional):** Number | ||
* **couponCode (optional):** String | ||
* **transaction (required):** Object | ||
* **id (required):** String | ||
* **affiliation (optional):** String, an entity with which the transaction should be affiliated (e.g. a particular store) | ||
* **revenue (optional):** Number | ||
* **tax (optional):** Number | ||
* **shipping (optional):** Number | ||
* **couponCode (optional):** String | ||
* **eventCategory (required):** String, defaults to "Ecommerce" | ||
* **eventAction (required):** String, defaults to "Purchase" | ||
### new GoogleAnalyticsTracker(trackerId, customDimensionsFieldsIndexMap) | ||
Save all tracker related data that is needed to call native methods with proper data. | ||
See the [Google Analytics docs](https://developers.google.com/analytics/devguides/collection/ios/v3/enhanced-ecommerce#measuring-transactions) for more info. | ||
```javascript | ||
tracker.trackPurchaseEvent({ | ||
id: 'P12345', | ||
name: 'Android Warhol T-Shirt', | ||
category: 'Apparel/T-Shirts', | ||
brand: 'Google', | ||
variant: 'Black', | ||
price: 29.20, | ||
quantity: 1, | ||
couponCode: 'APPARELSALE' | ||
}, { | ||
id: 'T12345', | ||
affiliation: 'Google Store - Online', | ||
revenue: 37.39, | ||
tax: 2.85, | ||
shipping: 5.34, | ||
couponCode: 'SUMMER2013' | ||
}, 'Ecommerce', 'Purchase'); | ||
``` | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| trackerId | <code>string</code> | Your tracker id, something like: UA-12345-1 | | ||
| customDimensionsFieldsIndexMap | <code>Object</code> | Custom dimensions field/index pairs | | ||
### trackMultiProductsPurchaseEvent(products, transaction, eventCategory, eventAction) | ||
same as trackPurchaseEvent but instead of one product you can provide an Array of products | ||
### trackMultiProductsPurchaseEventWithCustomDimensionValues(products, transaction, eventCategory, eventAction, dimensionIndexValueDict) | ||
* **products (required):** Array, array of products | ||
* **transaction (required):** Object, transaction object | ||
* **eventCategory (required):** String, defaults to "Ecommerce" | ||
* **eventAction (required):** String, defaults to "Purchase" | ||
* **dimensionIndexValueDict (required):** Dict of dimension index / values. | ||
```javascript | ||
tracker.trackMultiProductsPurchaseEventWithCustomDimensionValues([ | ||
{ | ||
id: 'P12345', | ||
name: 'Android Warhol T-Shirt', | ||
category: 'Apparel/T-Shirts', | ||
brand: 'Google', | ||
variant: 'Black', | ||
price: 29.20, | ||
quantity: 1, | ||
couponCode: 'APPARELSALE' | ||
}, | ||
{ | ||
id: 'P54321', | ||
name: 'IOS T-Shirt', | ||
category: 'Apparel/T-Shirts', | ||
brand: 'Apple', | ||
variant: 'Black', | ||
price: 10.10, | ||
quantity: 1, | ||
couponCode: 'APPARELSALE' | ||
}], | ||
{ | ||
id: 'T12345', | ||
affiliation: 'Store - Online', | ||
revenue: 52.5, | ||
tax: 7.86, | ||
shipping: 5.34, | ||
couponCode: 'SUMMER2013' | ||
}, | ||
'Ecommerce', | ||
'Purchase', | ||
{'1':'premium', '5':'foo'} | ||
); | ||
**Example** | ||
```js | ||
import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge'; | ||
let tracker = new GoogleAnalyticsTracker('UA-12345-1'); | ||
``` | ||
### trackException(error, fatal) | ||
<a name="GoogleAnalyticsTracker+trackScreenView"></a> | ||
* **error:** String, a description of the exception (up to 100 characters), accepts nil | ||
* **fatal (required):** Boolean, indicates whether the exception was fatal, defaults to false | ||
### tracker.trackScreenView(screenName, payload) | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
See the [Google Analytics docs](https://developers.google.com/analytics/devguides/collection/ios/v3/exceptions) for more info. | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| screenName | <code>string</code> | | (Required) The name of the current screen | | ||
| payload | <code>Object</code> | <code></code> | (Optional) An object containing the hit payload | | ||
```javascript | ||
try { | ||
... | ||
} catch(error) { | ||
tracker.trackException(error.message, false); | ||
} | ||
**Example** | ||
```js | ||
tracker.trackScreenView('Home') | ||
``` | ||
Track the current screen/view. Calling this will also set the "current view" for other calls. | ||
So events tracked will be tagged as having occured on the current view, `Home` in this example. | ||
This means it is important to track navigation, especially if events can fire on different views. | ||
<a name="GoogleAnalyticsTracker+trackEvent"></a> | ||
### trackSocialInteraction(network, action, targetUrl) | ||
### tracker.trackEvent(category, action, payload, label, value) | ||
Track an event that has occured | ||
* **network (required):** String, name of social network (e.g. 'Facebook', 'Twitter', 'Google+') | ||
* **action (required):** String, social action (e.g. 'Like', 'Share', '+1') | ||
* **targetUrl:** String, url of content being shared | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/social) docs for more info. | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| category | <code>string</code> | | (Required) The event category | | ||
| action | <code>string</code> | | (Required) The event action | | ||
| payload | <code>Object</code> | <code></code> | (Optional) An object containing the hit payload | | ||
| label | <code>string</code> | <code>null</code> | (Optional) An optional event label | | ||
| value | <code>number</code> | <code></code> | (Optional) An optional event value | | ||
```javascript | ||
tracker.trackSocialInteraction('Twitter', 'Post'); | ||
``` | ||
<a name="GoogleAnalyticsTracker+trackTiming"></a> | ||
### trackScreenViewWithCustomDimensionValues(screenName, dimensionIndexValueDict) | ||
### tracker.trackTiming(category, interval, payload, name, label) | ||
Track an event that has occured | ||
* **screenName (required):** String, name of current screen | ||
* **dimensionIndexValueDict (required):** Dict of dimension index / values. | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
Tracks a screen view with one or more customDimensionValues. See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/customdimsmets) docs for more info. | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| category | <code>string</code> | | (Required) The event category | | ||
| interval | <code>number</code> | | (Required) The timing measurement in milliseconds | | ||
| payload | <code>Object</code> | <code></code> | (Optional) An object containing the hit payload | | ||
| name | <code>string</code> | <code>null</code> | (Required) The timing name | | ||
| label | <code>string</code> | <code>null</code> | (Optional) An optional timing label | | ||
```javascript | ||
tracker.trackScreenViewWithCustomDimensionValues('Home', {'1':'premium', '5':'foo'}); | ||
``` | ||
<a name="GoogleAnalyticsTracker+trackException"></a> | ||
### trackEventWithCustomDimensionValues(category, action, optionalValues, dimensionIndexValueDict) | ||
### tracker.trackException(error, fatal, payload) | ||
Track an exception | ||
* **category (required):** String, category of event | ||
* **action (required):** String, name of action | ||
* **optionalValues:** Object | ||
* **label:** String | ||
* **value:** Number | ||
* **dimensionIndexValueDict (required):** Dict of dimension index / values. | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
Tracks an event with one or more customDimensionValues. See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/customdimsmets) docs for more info. | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| error | <code>string</code> | | (Required) The description of the error | | ||
| fatal | <code>boolean</code> | <code>false</code> | (Optional) A value indiciating if the error was fatal, defaults to false | | ||
| payload | <code>Object</code> | <code></code> | (Optional) An object containing the hit payload | | ||
```javascript | ||
tracker.trackEventWithCustomDimensionValues('testcategory', 'testaction', {label: 'v1.0.3', value: 22}, {'1':'premium', '5':'foo'}); | ||
``` | ||
### trackEventWithCustomDimensionAndMetricValues(category, action, optionalValues, dimensionIndexValueDict) | ||
<a name="GoogleAnalyticsTracker+trackSocialInteraction"></a> | ||
* **category (required):** String, category of event | ||
* **action (required):** String, name of action | ||
* **optionalValues:** Object | ||
* **label:** String | ||
* **value:** Number | ||
* **dimensionIndexValueDict (required):** Dict of dimension index / values. | ||
* **metricIndexValueDict (required):** Dict of metric index / values. | ||
### tracker.trackSocialInteraction(network, action, targetUrl, payload) | ||
Track a social interaction, Facebook, Twitter, etc. | ||
Tracks an event with one or more customDimensionValues and one or more customMetricValues. See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/customdimsmets) docs for more info. | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
```javascript | ||
tracker.trackEventWithCustomDimensionAndMetricValues('testcategory', 'testaction', {label: 'v1.0.3', value: 22}, {'1':'premium', '5':'foo'}, , {'1': 3, '5': 4}); | ||
``` | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| network | <code>string</code> | | | ||
| action | <code>string</code> | | | ||
| targetUrl | <code>string</code> | | | ||
| payload | <code>Object</code> | (Optional) An object containing the hit payload | | ||
### setUser(userId) | ||
<a name="GoogleAnalyticsTracker+setUser"></a> | ||
* **userId (required):** String, an **anonymous** identifier that complies with Google Analytic's user ID policy | ||
### tracker.setUser(userId) | ||
Sets the current userId for tracking. | ||
See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/user-id) for more info. | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
```javascript | ||
tracker.setUser('12345678'); | ||
``` | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| userId | <code>string</code> | The current userId | | ||
### setClient(clientId) | ||
<a name="GoogleAnalyticsTracker+setClient"></a> | ||
* **clientId (required):** String, an **anonymous** identifier that complies with Google Analytic's client ID policy | ||
### tracker.setClient(clientId) | ||
Sets the current clientId for tracking. | ||
See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) for more info. | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
```javascript | ||
tracker.setClient('35009a79-1a05-49d7-b876-2b884d0f825b'); | ||
``` | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| clientId | <code>string</code> | The current userId | | ||
### createNewSession(screenName) | ||
<a name="GoogleAnalyticsTracker+allowIDFA"></a> | ||
* **screenName (required):** String, the current screen which the session started on | ||
### tracker.allowIDFA(enabled) | ||
Sets if IDFA (identifier for advertisers) collection should be enabled | ||
See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/sessions#manual) for more info. | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
```javascript | ||
tracker.createNewSession('HomeScreen'); | ||
``` | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| enabled | <code>boolean</code> | <code>true</code> | (Optional) Defaults to true | | ||
### allowIDFA(enabled) | ||
<a name="GoogleAnalyticsTracker+setAppName"></a> | ||
* **enabled (required):** Boolean, true to allow IDFA collection, defaults to `true`. | ||
### tracker.setAppName(appName) | ||
Sets the trackers appName | ||
The Bundle name is used by default | ||
Also called advertising identifier collection, and is used for advertising features. | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
**Important**: For iOS you can only use this method if you have done the optional step 6 from the installation guide. Only enable this (and link the appropriate libraries) if you plan to use advertising features in your app, or else your app may get rejected from the AppStore. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| appName | <code>string</code> | (Required) | | ||
See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/campaigns#ios-install) for more info. | ||
<a name="GoogleAnalyticsTracker+setAppVersion"></a> | ||
```javascript | ||
tracker.allowIDFA(true); | ||
``` | ||
### tracker.setAppVersion(appVersion) | ||
Sets the trackers appVersion | ||
### setTrackUncaughtExceptions(enabled) | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
* **enabled (required):** Boolean | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| appVersion | <code>string</code> | (Required) | | ||
Sets if uncaught exceptions should be tracked. This is enabled by default. | ||
<a name="GoogleAnalyticsTracker+setAnonymizeIp"></a> | ||
```javascript | ||
tracker.setTrackUncaughtExceptions(true); | ||
``` | ||
### tracker.setAnonymizeIp(enabled) | ||
Sets if AnonymizeIp is enabled | ||
If enabled the last octet of the IP address will be removed | ||
### setAnonymizeIp(enabled) | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
* **enabled (required):** Boolean | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| enabled | <code>boolean</code> | (Required) | | ||
Sets if AnonymizeIp is enabled. This is disabled by default. | ||
If enabled the last octet of the IP address will be removed. | ||
<a name="GoogleAnalyticsTracker+setSamplingRate"></a> | ||
```javascript | ||
tracker.setAnonymizeIp(true); | ||
``` | ||
### setAppName(appName) | ||
* **appName (required):** String | ||
Overrides the app name logged in Google Analytics. The Bundle name is used by default. | ||
Note: This has to be set each time the App starts. | ||
```javascript | ||
tracker.setAppName('someAppName'); | ||
``` | ||
### setSamplingRate(ratio) | ||
* **ratio (required):** Number Percentage 0 - 100 | ||
### tracker.setSamplingRate(sampleRatio) | ||
Sets tracker sampling rate. | ||
```javascript | ||
tracker.setSamplingRate(50); | ||
``` | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
### setCurrency(currencyCode) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| sampleRatio | <code>number</code> | (Required) Percentage 0 - 100 | | ||
* **currencyCode (required):** String, ISO 4217 currency code | ||
<a name="GoogleAnalyticsTracker+setCurrency"></a> | ||
Sets tracker currency property, see [Currency Codes](https://developers.google.com/analytics/devguides/platform/features/currencies). | ||
### tracker.setCurrency(currencyCode) | ||
Sets the currency for tracking. | ||
```javascript | ||
tracker.setCurrency('EUR'); | ||
``` | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
## GoogleAnalyticsSettings API | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| currencyCode | <code>string</code> | (Required) The currency ISO 4217 code | | ||
Settings are applied across all trackers. | ||
<a name="GoogleAnalyticsTracker+setTrackUncaughtExceptions"></a> | ||
### setDryRun(enabled) | ||
### tracker.setTrackUncaughtExceptions(enabled) | ||
Sets if uncaught exceptions should be tracked | ||
Important to note: On iOS this option is set on all trackers. On Android it is set per tracker. | ||
If you are using multiple trackers on iOS, this will enable & disable on all trackers. | ||
* **enabled (required):** Boolean, indicating if the `dryRun` flag should be enabled or not. | ||
**Kind**: instance method of [<code>GoogleAnalyticsTracker</code>](#GoogleAnalyticsTracker) | ||
When enabled the native library prevents any data from being sent to Google Analytics. This allows you to test or debug the implementation, without your test data appearing in your Google Analytics reports. | ||
| Param | Type | | ||
| --- | --- | | ||
| enabled | <code>boolean</code> | | ||
```javascript | ||
GoogleAnalyticsSettings.setDryRun(true); | ||
``` | ||
<a name="GoogleTagManager"></a> | ||
### setDispatchInterval(intervalInSeconds) | ||
## GoogleTagManager | ||
**Kind**: global class | ||
* **intervalInSeconds (required):** Number, indicating how often dispatches should be sent | ||
* [GoogleTagManager](#GoogleTagManager) | ||
* [.openContainerWithId(containerId)](#GoogleTagManager.openContainerWithId) ⇒ <code>Promise.<boolean></code> | ||
* [.boolForKey(key)](#GoogleTagManager.boolForKey) ⇒ <code>Promise.<boolean></code> | ||
* [.stringForKey(key)](#GoogleTagManager.stringForKey) ⇒ <code>Promise.<string></code> | ||
* [.doubleForKey(key)](#GoogleTagManager.doubleForKey) ⇒ <code>Promise.<number></code> | ||
* [.pushDataLayerEvent(event)](#GoogleTagManager.pushDataLayerEvent) ⇒ <code>Promise.<boolean></code> | ||
Events, screen views, etc, are sent in batches to your tracker. This function allows you to configure how often (in seconds) the batches are sent to your tracker. Recommended to keep this around 20-120 seconds to preserve battery and network traffic. | ||
This is set to 20 seconds by default. | ||
<a name="GoogleTagManager.openContainerWithId"></a> | ||
```javascript | ||
GoogleAnalyticsSettings.setDispatchInterval(30); | ||
``` | ||
### GoogleTagManager.openContainerWithId(containerId) ⇒ <code>Promise.<boolean></code> | ||
Call once to open the container for all subsequent static calls. | ||
### setOptOut(enabled) | ||
**Kind**: static method of [<code>GoogleTagManager</code>](#GoogleTagManager) | ||
* **enabled (required):** Boolean | ||
| Param | Type | | ||
| --- | --- | | ||
| containerId | <code>string</code> | | ||
Sets if OptOut is active and disables Google Analytics. This is disabled by default. | ||
Note: This has to be set each time the App starts. | ||
<a name="GoogleTagManager.boolForKey"></a> | ||
```javascript | ||
GoogleAnalyticsSettings.setOptOut(true); | ||
``` | ||
### GoogleTagManager.boolForKey(key) ⇒ <code>Promise.<boolean></code> | ||
Retrieves a boolean value with the given key from the opened container. | ||
## GoogleTagManager API | ||
**Kind**: static method of [<code>GoogleTagManager</code>](#GoogleTagManager) | ||
```javascript | ||
import { GoogleTagManager } from 'react-native-google-analytics-bridge'; | ||
GoogleTagManager.openContainerWithId('GT-NZT48') | ||
.then(() => GoogleTagManager.stringForKey('pack')) | ||
.then((str) => console.log('Pack: ', str)); | ||
``` | ||
| Param | Type | | ||
| --- | --- | | ||
| key | <code>string</code> | | ||
Can only be used with one container. All methods returns a `Promise`. | ||
<a name="GoogleTagManager.stringForKey"></a> | ||
### openContainerWithId(containerId) | ||
* **containerId (required):** String, your container id. | ||
**Important**: Call **once** to open the container for all subsequent static calls. | ||
```javascript | ||
GoogleTagManager.openContainerWithId('GT-NZT48') | ||
.then((..) => ..) | ||
``` | ||
### stringForKey(key) | ||
##### Parameter(s) | ||
* **key (required):** String | ||
##### Returns: | ||
* **value:** String | ||
### GoogleTagManager.stringForKey(key) ⇒ <code>Promise.<string></code> | ||
Retrieves a string with the given key from the opened container. | ||
```javascript | ||
GoogleTagManager.stringForKey('key').then((val) => console.log(val)); | ||
``` | ||
**Kind**: static method of [<code>GoogleTagManager</code>](#GoogleTagManager) | ||
### boolForKey(key) | ||
##### Parameter(s) | ||
* **key (required):** String | ||
| Param | Type | | ||
| --- | --- | | ||
| key | <code>string</code> | | ||
##### Returns: | ||
* **value:** Boolean | ||
<a name="GoogleTagManager.doubleForKey"></a> | ||
Retrieves a boolean value with the given key from the opened container. | ||
### GoogleTagManager.doubleForKey(key) ⇒ <code>Promise.<number></code> | ||
Retrieves a number with the given key from the opened container. | ||
```javascript | ||
GoogleTagManager.boolForKey('key').then((val) => console.log(val)); | ||
``` | ||
**Kind**: static method of [<code>GoogleTagManager</code>](#GoogleTagManager) | ||
### doubleForKey(key) | ||
##### Parameter(s) | ||
* **key (required):** String | ||
| Param | Type | | ||
| --- | --- | | ||
| key | <code>string</code> | | ||
##### Returns: | ||
* **value:** Number | ||
<a name="GoogleTagManager.pushDataLayerEvent"></a> | ||
Retrieves a number with the given key from the opened container. | ||
### GoogleTagManager.pushDataLayerEvent(event) ⇒ <code>Promise.<boolean></code> | ||
Push a datalayer event for Google Analytics through Google Tag Manager. The event must have at least one key "event" with event name. | ||
You can add optional values on top of that, example: {event: "eventName", pageId: "/home"} | ||
```javascript | ||
GoogleTagManager.doubleForKey('key').then((val) => console.log(val)); | ||
``` | ||
**Kind**: static method of [<code>GoogleTagManager</code>](#GoogleTagManager) | ||
### pushDataLayerEvent(dictionary = {}) | ||
##### Parameter(s) | ||
* **dictionary (required):** dictionary An Map<String, Object> containing key and value pairs. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| event | <code>Object</code> | An Map<String, Object> containing key and value pairs. It must have at least one key "event" with event name | | ||
##### Returns: | ||
* **value:** Boolean | ||
Push a DataLayer event for Google Analytics through Google Tag Manager. | ||
```javascript | ||
GoogleTagManager.pushDataLayerEvent({event: "eventName", pageId: "/home"}) | ||
.then((success) => console.log(success)); | ||
``` |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
35753439
63
1409
7
419
3