{"id":4435,"url":"https://github.com/idehub/react-native-google-analytics-bridge","last_synced_at":"2025-08-04T01:32:45.346Z","repository":{"id":57124947,"uuid":"47023699","full_name":"idehub/react-native-google-analytics-bridge","owner":"idehub","description":"React Native bridge to the Google Analytics libraries on both iOS and Android.","archived":true,"fork":false,"pushed_at":"2019-03-15T18:02:47.000Z","size":46895,"stargazers_count":1154,"open_issues_count":0,"forks_count":253,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-10-30T01:02:52.532Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idehub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-28T13:02:55.000Z","updated_at":"2024-04-15T20:37:06.000Z","dependencies_parsed_at":"2022-08-31T08:20:59.151Z","dependency_job_id":null,"html_url":"https://github.com/idehub/react-native-google-analytics-bridge","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idehub%2Freact-native-google-analytics-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idehub%2Freact-native-google-analytics-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idehub%2Freact-native-google-analytics-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idehub%2Freact-native-google-analytics-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idehub","download_url":"https://codeload.github.com/idehub/react-native-google-analytics-bridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228582487,"owners_count":17940587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:11.885Z","updated_at":"2024-12-07T08:30:41.924Z","avatar_url":"https://github.com/idehub.png","language":"Objective-C","funding_links":[],"categories":["Components"],"sub_categories":["Analytics"],"readme":"# Deprecation notice\n\nOn November 13th 2018 Google issued the following statement:\n\n\u003e We want to let you know that in October 2019 we will begin to sunset our Google Analytics for mobile apps reporting and the Google Analytics Services SDK. \n\u003e\n\u003e Data collection and processing for such properties will stop on October 31, 2019. \n\nThe message is quite clear, and therefore I am officially deprecating this library. If you want to continue using Google's solutions for analytics, I recommend you move to Google Analytics for Firebase instead. \n\nFor React Native, there is a great library called [react-native-firebase](https://github.com/invertase/react-native-firebase) which implements Analytics (and other Firebase solutions).\n\nI will continue to support this library for minor fixes, but no major changes will occur. The repository itself will be archived sometime in 2019.\n\nThanks to everyone who have used or contributed to this library!\n\n\\- Christian ([@cbrevik](https://github.com/cbrevik))\n\n# 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)\n\n**Google Analytics Bridge** is built to provide an easy interface to the native Google Analytics libraries on both **iOS** and **Android**.\n\n## Why a native bridge? Why not use just JavaScript?\n\nThe key difference with the native bridge is that you get a lot of the metadata handled automatically by the Google Analytics native library. This will include the device UUID, device model, viewport size, OS version etc.\n\nYou will only have to send in a few parameteres when tracking, e.g:\n\n```javascript\nimport { GoogleAnalyticsTracker } from \"react-native-google-analytics-bridge\";\nlet tracker = new GoogleAnalyticsTracker(\"UA-12345-1\");\n\ntracker.trackScreenView(\"Home\");\ntracker.trackEvent(\"testcategory\", \"testaction\");\n```\n\n## Version 6 breaking changes!\n\nIf you are upgrading to version 6 from an older version, read [this wiki post for important details](https://github.com/idehub/react-native-google-analytics-bridge/wiki/Version-6-breaking-changes).\n\nThe newest version of this library has a new API surface. The API changes are in most cases backwards-compatible.\n\n[**Important**: If you are using ecommerce or custom dimensions, you probably have to migrate to new API if you upgrade!](https://github.com/idehub/react-native-google-analytics-bridge/wiki/Version-6-breaking-changes#migrating-to-new-api)\n\n## Content\n\n-   [Installation](#installation-and-linking-libraries)\n-   [Manual installation](https://github.com/idehub/react-native-google-analytics-bridge/wiki/Manual-installation)\n-   [Usage](#usage)\n-   [JavaScript API](#javascript-api)\n-   [Problems with the library?](https://github.com/idehub/react-native-google-analytics-bridge/wiki/Troubleshooting)\n-   [See wiki for more helpful topics](https://github.com/idehub/react-native-google-analytics-bridge/wiki)\n\n## Installation and linking libraries\n\n-   For React Native \u003e= `0.40` use version `5.0.0` (and up) of this module.\n-   For React Native \u0026lt; `0.40` use version `4.0.3`.\n\nInstall with npm: `npm install --save react-native-google-analytics-bridge`\n\nOr, install with yarn: `yarn add react-native-google-analytics-bridge`\n\nEither way, then link with: `react-native link react-native-google-analytics-bridge`\n\nIf it doesn't work immediately after this, consult the [manual installation guide](https://github.com/idehub/react-native-google-analytics-bridge/wiki/Manual-installation). Both Android and iOS has a couple of prerequisite SDKs linked and installed.\n\n**Important**: Does this library work with Expo? We have to sort of invert the question a bit, because it should be: does Expo work with other libraries? And the [answer is no](https://docs.expo.io/versions/latest/introduction/faq.html#what-is-the-difference-between-expo-and-react-native):\n\n\u003e The most limiting thing about Expo is that you can’t add in your own native modules without `detach`ing and using ExpoKit.\n\nThis includes using [`create-react-native-app`](https://github.com/react-community/create-react-native-app#what-are-the-limitations-of-create-react-native-app) which also makes use of Expo.\n\n## Usage\n\n```javascript\n// You have access to three classes in this module:\nimport {\n  GoogleAnalyticsTracker,\n  GoogleTagManager,\n  GoogleAnalyticsSettings\n} from \"react-native-google-analytics-bridge\";\n\n// The tracker must be constructed, and you can have multiple:\nlet tracker1 = new GoogleAnalyticsTracker(\"UA-12345-1\");\nlet tracker2 = new GoogleAnalyticsTracker(\"UA-12345-2\");\n\ntracker1.trackScreenView(\"Home\");\ntracker1.trackEvent(\"Customer\", \"New\");\n\n// The GoogleAnalyticsSettings is static, and settings are applied across all trackers:\nGoogleAnalyticsSettings.setDispatchInterval(30);\n// Setting `dryRun` to `true` lets you test tracking without sending data to GA\nGoogleAnalyticsSettings.setDryRun(true);\n\n// GoogleTagManager is also static, and works only with one container. All functions here are Promises:\nGoogleTagManager.openContainerWithId(\"GT-NZT48\")\n  .then(() =\u003e {\n    return GoogleTagManager.stringForKey(\"pack\");\n  })\n  .then(pack =\u003e {\n    console.log(\"Pack: \", pack);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\n// You can also register Function Call tag handlers when the container is open.\nGoogleTagManager.registerFunctionCallTagHandler(\n  \"some_function\", // Must be equal to Function Name field when the tag was configured.\n  (functionName, tagArguments) =\u003e {\n    // functionName is passed for convenience. In this example it will be equal to \"some_function\".\n    // tagArguments is an object and is populated based on Tag configuration in TagManager interface.\n    console.log(\"Handling Function Call tag:\", functionName);\n  }\n)\n```\n\n## JavaScript API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n#### Table of Contents\n\n-   [GoogleAnalyticsSettings](#googleanalyticssettings)\n    -   [setOptOut](#setoptout)\n        -   [Parameters](#parameters)\n        -   [Examples](#examples)\n    -   [setDispatchInterval](#setdispatchinterval)\n        -   [Parameters](#parameters-1)\n        -   [Examples](#examples-1)\n    -   [setDryRun](#setdryrun)\n        -   [Parameters](#parameters-2)\n        -   [Examples](#examples-2)\n-   [GoogleAnalyticsTracker](#googleanalyticstracker)\n    -   [Examples](#examples-3)\n    -   [trackScreenView](#trackscreenview)\n        -   [Parameters](#parameters-3)\n        -   [Examples](#examples-4)\n    -   [trackEvent](#trackevent)\n        -   [Parameters](#parameters-4)\n        -   [Examples](#examples-5)\n    -   [trackTiming](#tracktiming)\n        -   [Parameters](#parameters-5)\n        -   [Examples](#examples-6)\n    -   [trackException](#trackexception)\n        -   [Parameters](#parameters-6)\n        -   [Examples](#examples-7)\n    -   [trackSocialInteraction](#tracksocialinteraction)\n        -   [Parameters](#parameters-7)\n        -   [Examples](#examples-8)\n    -   [setUser](#setuser)\n        -   [Parameters](#parameters-8)\n        -   [Examples](#examples-9)\n    -   [setClient](#setclient)\n        -   [Parameters](#parameters-9)\n        -   [Examples](#examples-10)\n    -   [getClientId](#getclientid)\n        -   [Examples](#examples-11)\n    -   [allowIDFA](#allowidfa)\n        -   [Parameters](#parameters-10)\n        -   [Examples](#examples-12)\n    -   [setAppName](#setappname)\n        -   [Parameters](#parameters-11)\n        -   [Examples](#examples-13)\n    -   [setAppVersion](#setappversion)\n        -   [Parameters](#parameters-12)\n        -   [Examples](#examples-14)\n    -   [setAnonymizeIp](#setanonymizeip)\n        -   [Parameters](#parameters-13)\n        -   [Examples](#examples-15)\n    -   [setSamplingRate](#setsamplingrate)\n        -   [Parameters](#parameters-14)\n        -   [Examples](#examples-16)\n    -   [setCurrency](#setcurrency)\n        -   [Parameters](#parameters-15)\n        -   [Examples](#examples-17)\n    -   [setTrackUncaughtExceptions](#settrackuncaughtexceptions)\n        -   [Parameters](#parameters-16)\n    -   [dispatch](#dispatch)\n        -   [Examples](#examples-18)\n    -   [dispatchWithTimeout](#dispatchwithtimeout)\n        -   [Parameters](#parameters-17)\n        -   [Examples](#examples-19)\n-   [GoogleTagManager](#googletagmanager)\n    -   [Examples](#examples-20)\n    -   [openContainerWithId](#opencontainerwithid)\n        -   [Parameters](#parameters-18)\n        -   [Examples](#examples-21)\n    -   [refreshContainer](#refreshcontainer)\n        -   [Examples](#examples-22)\n    -   [boolForKey](#boolforkey)\n        -   [Parameters](#parameters-19)\n        -   [Examples](#examples-23)\n    -   [stringForKey](#stringforkey)\n        -   [Parameters](#parameters-20)\n        -   [Examples](#examples-24)\n    -   [doubleForKey](#doubleforkey)\n        -   [Parameters](#parameters-21)\n        -   [Examples](#examples-25)\n    -   [pushDataLayerEvent](#pushdatalayerevent)\n        -   [Parameters](#parameters-22)\n        -   [Examples](#examples-26)\n    -   [registerFunctionCallTagHandler](#registerfunctioncalltaghandler)\n        -   [Parameters](#parameters-23)\n    -   [setVerboseLoggingEnabled](#setverboseloggingenabled)\n        -   [Parameters](#parameters-24)\n-   [TimingMetadata](#timingmetadata)\n    -   [Parameters](#parameters-25)\n    -   [Examples](#examples-27)\n-   [EventMetadata](#eventmetadata)\n    -   [Parameters](#parameters-26)\n    -   [Examples](#examples-28)\n-   [HitPayload](#hitpayload)\n    -   [Parameters](#parameters-27)\n    -   [Examples](#examples-29)\n-   [CustomDimensionsByField](#customdimensionsbyfield)\n    -   [Examples](#examples-30)\n-   [CustomDimensionsByIndex](#customdimensionsbyindex)\n    -   [Examples](#examples-31)\n-   [CustomDimensionsFieldIndexMap](#customdimensionsfieldindexmap)\n    -   [Examples](#examples-32)\n-   [CustomMetrics](#custommetrics)\n    -   [Examples](#examples-33)\n-   [DataLayerEvent](#datalayerevent)\n    -   [Parameters](#parameters-28)\n    -   [Examples](#examples-34)\n-   [ProductActionEnum](#productactionenum)\n-   [Product](#product)\n    -   [Parameters](#parameters-29)\n    -   [Examples](#examples-35)\n-   [ProductAction](#productaction)\n    -   [Parameters](#parameters-30)\n    -   [Examples](#examples-36)\n-   [Transaction](#transaction)\n    -   [Parameters](#parameters-31)\n    -   [Examples](#examples-37)\n\n### GoogleAnalyticsSettings\n\nSettings which are applied across all trackers.\n\n#### setOptOut\n\nSets if OptOut is active and disables Google Analytics. This is disabled by default. Note: This has to be set each time the App starts.\n\n##### Parameters\n\n-   `enabled` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \n\n##### Examples\n\n```javascript\nGoogleAnalyticsSettings.setOptOut(true);\n```\n\n#### setDispatchInterval\n\nSets the trackers dispatch interval.\nEvents, 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.\n\n##### Parameters\n\n-   `intervalInSeconds` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n\n##### Examples\n\n```javascript\nGoogleAnalyticsSettings.setDispatchInterval(30);\n```\n\n#### setDryRun\n\nWhen 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.\n\n##### Parameters\n\n-   `enabled` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \n\n##### Examples\n\n```javascript\nGoogleAnalyticsSettings.setDryRun(true);\n```\n\n### GoogleAnalyticsTracker\n\n#### Examples\n\n```javascript\n// Constructing a tracker is simple:\nimport { GoogleAnalyticsTracker } from \"react-native-google-analytics-bridge\";\nconst tracker = new GoogleAnalyticsTracker(\"UA-12345-1\");\ntracker.trackScreenView(\"Home\");\n\n// You can have multiple trackers if you have several tracking ids\nconst tracker2 = new GoogleAnalyticsTracker(\"UA-12345-2\");\n```\n\n```javascript\n// One optional feature as well is constructing a tracker with a CustomDimensionsFieldIndexMap, to map custom dimension field names to index keys:\nconst fieldIndexMap = { customerType: 1 };\nconst tracker3 = new GoogleAnalyticsTracker(\"UA-12345-3\", fieldIndexMap);\n\n// This is because the Google Analytics API expects custom dimensions to be tracked by index keys, and not field names.\n// Here the underlying logic will transform the custom dimension, so what ends up being sent to GA is { 1: 'Premium' }:\ntracker3.trackScreenView(\"Home\", { customDimensions: { customerType: \"Premium\" } });\n\n// If you do not use a CustomDimensionsFieldIndexMap, you will have to use index as keys instead for custom dimensions:\ntracker.trackScreenView(\"Home\", { customDimensions: { 1: \"Premium\" } });\n```\n\n#### trackScreenView\n\nTrack the current screen/view. Calling this will also set the \"current view\" for other calls.\n So events tracked will be tagged as having occured on the current view, `Home` in this example.\nThis means it is important to track navigation, especially if events can fire on different views.\n\n##### Parameters\n\n-   `screenName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required) The name of the current screen\n-   `payload` **[HitPayload](#hitpayload)** (Optional) An object containing the hit payload (optional, default `null`)\n\n##### Examples\n\n```javascript\ntracker.trackScreenView('Home');\n```\n\n```javascript\n// With payload:\nconst payload = { impressionList: \"Sale\", impressionProducts: [ { id: \"PW928\", name: \"Premium bundle\" } ] };\ntracker.trackScreenView(\"SplashModal\", payload);\n```\n\n#### trackEvent\n\nTrack an event that has occured\n\n##### Parameters\n\n-   `category` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required) The event category\n-   `action` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required) The event action\n-   `eventMetadata` **[EventMetadata](#eventmetadata)** (Optional) An object containing event metadata\n-   `payload` **[HitPayload](#hitpayload)** (Optional) An object containing the hit payload (optional, default `null`)\n\n##### Examples\n\n```javascript\ntracker.trackEvent(\"DetailsButton\", \"Click\");\n```\n\n```javascript\n// Track event with label and value\ntracker.trackEvent(\"AppVersionButton\", \"Click\", { label: \"v1.0.3\", value: 22 });\n```\n\n```javascript\n// Track with a payload (ecommerce in this case):\nconst product = {\n  id: \"P12345\",\n  name: \"Android Warhol T-Shirt\",\n  category: \"Apparel/T-Shirts\",\n  brand: \"Google\",\n  variant: \"Black\",\n  price: 29.2,\n  quantity: 1,\n  couponCode: \"APPARELSALE\"\n};\nconst transaction = {\n  id: \"T12345\",\n  affiliation: \"Google Store - Online\",\n  revenue: 37.39,\n  tax: 2.85,\n  shipping: 5.34,\n  couponCode: \"SUMMER2013\"\n};\nconst productAction = {\n  transaction,\n  action: 7 // Purchase action, see ProductActionEnum\n}\nconst payload = { products: [ product ], productAction: productAction }\ntracker.trackEvent(\"FinalizeOrderButton\", \"Click\", null, payload);\n```\n\n#### trackTiming\n\nTrack a timing measurement\n\n##### Parameters\n\n-   `category` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required) The event category\n-   `interval` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Required) The timing measurement in milliseconds\n-   `timingMetadata` **[TimingMetadata](#timingmetadata)** (Required) An object containing timing metadata\n-   `payload` **[HitPayload](#hitpayload)** (Optional) An object containing the hit payload (optional, default `null`)\n\n##### Examples\n\n```javascript\ntracker.trackTiming(\"testcategory\", 2000, { name: \"LoadList\" }); // name metadata is required\n```\n\n```javascript\n// With optional label:\ntracker.trackTiming(\"testcategory\", 2000, { name: \"LoadList\", label: \"v1.0.3\" });\n```\n\n#### trackException\n\nTrack an exception\n\n##### Parameters\n\n-   `error` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required) The description of the error\n-   `fatal` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (Optional) A value indiciating if the error was fatal, defaults to false (optional, default `false`)\n-   `payload` **[HitPayload](#hitpayload)** (Optional) An object containing the hit payload (optional, default `null`)\n\n##### Examples\n\n```javascript\ntry {\n  ...\n} catch(error) {\n  tracker.trackException(error.message, false);\n}\n```\n\n#### trackSocialInteraction\n\nTrack a social interaction, Facebook, Twitter, etc.\n\n##### Parameters\n\n-   `network` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `action` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `targetUrl` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `payload` **[HitPayload](#hitpayload)** (Optional) An object containing the hit payload\n\n##### Examples\n\n```javascript\ntracker.trackSocialInteraction(\"Twitter\", \"Post\");\n```\n\n#### setUser\n\nSets the current userId for tracking.\n\n##### Parameters\n\n-   `userId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** An anonymous identifier that complies with Google Analytic's user ID policy\n\n##### Examples\n\n```javascript\ntracker.setUser(\"12345678\");\n```\n\n#### setClient\n\nSets the current clientId for tracking.\n\n##### Parameters\n\n-   `clientId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A anonymous identifier that complies with Google Analytic's client ID policy\n\n##### Examples\n\n```javascript\ntracker.setClient(\"35009a79-1a05-49d7-b876-2b884d0f825b\");\n```\n\n#### getClientId\n\nGet the client id to be used for purpose of logging etc.\n\n##### Examples\n\n```javascript\ntracker.getClientId().then(clientId =\u003e console.log(\"Client id is: \", clientId));\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e** \n\n#### allowIDFA\n\nAlso called advertising identifier collection, and is used for advertising features.\n\n**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.\n\n##### Parameters\n\n-   `enabled` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (Optional) Defaults to true (optional, default `true`)\n\n##### Examples\n\n```javascript\ntracker.allowIDFA(true);\n```\n\n#### setAppName\n\nOverrides 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.\n\n##### Parameters\n\n-   `appName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required)\n\n##### Examples\n\n```javascript\ntracker.setAppName(\"YourAwesomeApp\");\n```\n\n#### setAppVersion\n\nSets the trackers appVersion\n\n##### Parameters\n\n-   `appVersion` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required)\n\n##### Examples\n\n```javascript\ntracker.setAppVersion(\"1.3.2\");\n```\n\n#### setAnonymizeIp\n\nSets if AnonymizeIp is enabled\nIf enabled the last octet of the IP address will be removed\n\n##### Parameters\n\n-   `enabled` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (Required)\n\n##### Examples\n\n```javascript\ntracker.setAnonymizeIp(true);\n```\n\n#### setSamplingRate\n\nSets tracker sampling rate.\n\n##### Parameters\n\n-   `sampleRatio` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Required) Percentage 0 - 100\n\n##### Examples\n\n```javascript\ntracker.setSamplingRate(50);\n```\n\n#### setCurrency\n\nSets the currency for tracking.\n\n##### Parameters\n\n-   `currencyCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required) The currency ISO 4217 code\n\n##### Examples\n\n```javascript\ntracker.setCurrency(\"EUR\");\n```\n\n#### setTrackUncaughtExceptions\n\nSets if uncaught exceptions should be tracked\nImportant to note: On iOS this option is set on all trackers. On Android it is set per tracker.\nIf you are using multiple trackers on iOS, this will enable \u0026 disable on all trackers.\n\n##### Parameters\n\n-   `enabled` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \n\n#### dispatch\n\nThis function lets you manually dispatch all hits which are queued.\nUse this function sparingly, as it will normally happen automatically\nas a batch. This function will also dispatch for all trackers.\n\n##### Examples\n\n```javascript\ntracker.dispatch().then(done =\u003e console.log(\"Dispatch is done: \", done));\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\u003e** Returns when done\n\n#### dispatchWithTimeout\n\nThe same as `dispatch`, but also gives you the ability to time out\nthe Promise in case dispatch takes too long.\n\n##### Parameters\n\n-   `timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The timeout. Default value is 15 sec. (optional, default `-1`)\n\n##### Examples\n\n```javascript\ntracker\n  .dispatchWithTimeout(10000)\n  .then(done =\u003e console.log(\"Dispatch is done: \", done));\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\u003e** Returns when done or timed out\n\n### GoogleTagManager\n\nCan only be used with one container. All functions returns a Promise.\n\n#### Examples\n\n```javascript\nimport { GoogleTagManager } from \"react-native-google-analytics-bridge\";\nGoogleTagManager.openContainerWithId(\"GT-NZT48\")\n  .then(() =\u003e GoogleTagManager.stringForKey(\"pack\"))\n  .then(str =\u003e console.log(\"Pack: \", str));\n```\n\n#### openContainerWithId\n\nCall once to open the container for all subsequent static calls.\n\n##### Parameters\n\n-   `containerId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n##### Examples\n\n```javascript\nGoogleTagManager.openContainerWithId('GT-NZT48').then((..) =\u003e ..)\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\u003e** \n\n#### refreshContainer\n\nRefreshes the GTM container.\nAccording to Tag Manager documentations for Android can be called once every 15 minutes.\nNo such limitations has been mentioned for iOS containers, though.\n\n##### Examples\n\n```javascript\nGoogleTagManager.refreshContainer().then((..) =\u003e ..)\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\u003e** \n\n#### boolForKey\n\nRetrieves a boolean value with the given key from the opened container.\n\n##### Parameters\n\n-   `key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n##### Examples\n\n```javascript\nGoogleTagManager.boolForKey(\"key\").then(val =\u003e console.log(val));\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\u003e** \n\n#### stringForKey\n\nRetrieves a string with the given key from the opened container.\n\n##### Parameters\n\n-   `key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n##### Examples\n\n```javascript\nGoogleTagManager.stringForKey(\"key\").then(val =\u003e console.log(val));\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e** \n\n#### doubleForKey\n\nRetrieves a number with the given key from the opened container.\n\n##### Parameters\n\n-   `key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n##### Examples\n\n```javascript\nGoogleTagManager.doubleForKey(\"key\").then(val =\u003e console.log(val));\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)\u003e** \n\n#### pushDataLayerEvent\n\nPush a datalayer event for Google Analytics through Google Tag Manager. The event must have at least one key \"event\" with event name.\n\n##### Parameters\n\n-   `event` **[DataLayerEvent](#datalayerevent)** An Map\u0026lt;String, Object\u003e containing key and value pairs. It must have at least one key \"event\" with event name\n\n##### Examples\n\n```javascript\nGoogleTagManager.pushDataLayerEvent({\n  event: \"eventName\",\n  pageId: \"/home\"\n}).then(success =\u003e console.log(success));\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\u003e** \n\n#### registerFunctionCallTagHandler\n\nRegister Function Call tag handler\n\n##### Parameters\n\n-   `functionName` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `handler` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** \n\n#### setVerboseLoggingEnabled\n\nSets logger to verbose, default is warning\n\n##### Parameters\n\n-   `enabled` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \n\n### TimingMetadata\n\nUsed when tracking time measurements\n\n#### Parameters\n\n-   `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Required)\n-   `label` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n\n#### Examples\n\n```javascript\nconst timingMetadata = { name: \"LoadList\" } // name is a required value when tracking timing\ntracker.trackTiming(\"testcategory\", 13000, timingMetadata);\n```\n\n### EventMetadata\n\nUsed when tracking event\n\n#### Parameters\n\n-   `label` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n-   `value` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Optional)\n\n#### Examples\n\n```javascript\nconst eventMetadata = { label: \"v1.0.3\", value: 22 }\ntracker.trackEvent(\"FinalizeOrderButton\", \"Click\", eventMetadata);\n```\n\n### HitPayload\n\nThe HitPayload object and possible values\n\nUsed by the different tracking methods for adding metadata to the hit.\n\n#### Parameters\n\n-   `products` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Product](#product)\u003e** (Optional) Used for ecommerce\n-   `impressionProducts` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Product](#product)\u003e** (Optional) Used for ecommerce\n-   `impressionList` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional) Used for ecommerce\n-   `impressionSource` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional) Used for ecommerce\n-   `productAction` **[ProductAction](#productaction)** (Optional) Used for ecommerce\n-   `customDimensions` **([CustomDimensionsByIndex](#customdimensionsbyindex) \\| [CustomDimensionsByField](#customdimensionsbyfield))** (Optional)\n-   `customMetrics` **[CustomMetrics](#custommetrics)** (Optional)\n-   `utmCampaignUrl` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional) Used for campaigns\n-   `session` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional) Only two possible values, \"start\" or \"end\". This will either start or end a session.\n\n#### Examples\n\n```javascript\n// If you want to do send a purchase payload with an event:\nconst product = {\n  id: \"P12345\",\n  name: \"Android Warhol T-Shirt\",\n  category: \"Apparel/T-Shirts\",\n  brand: \"Google\",\n  variant: \"Black\",\n  price: 29.2,\n  quantity: 1,\n  couponCode: \"APPARELSALE\"\n};\nconst transaction = {\n  id: \"T12345\",\n  affiliation: \"Google Store - Online\",\n  revenue: 37.39,\n  tax: 2.85,\n  shipping: 5.34,\n  couponCode: \"SUMMER2013\"\n};\nconst productAction = {\n  transaction,\n  action: 7 // Purchase action, see ProductActionEnum\n}\nconst payload = { products: [ product ], productAction: productAction }\ntracker.trackEvent(\"FinalizeOrderButton\", \"Click\", null, payload);\n```\n\n```javascript\n// If you want to send custom dimensions with a screen view:\nconst customDimensions = {\n  1: \"Beta\",\n  3: \"Premium\"\n};\nconst payload = { customDimensions };\ntracker.trackScreenView(\"SaleScreen\", payload);\n```\n\n### CustomDimensionsByField\n\n-   **See: CustomDimensionsFieldIndexMap**\n-   **See: CustomDimensionsByIndex**\n\nA dictionary with custom dimensions values and their (mapped) field name keys.\nIn order to use this and send in custom dimensions by field name, you must have\nprovided a `CustomDimensionsFieldIndexMap` when constructing the tracker.\n\n#### Examples\n\n```javascript\nconst customDimensions = { customerType: \"Premium\", appType: \"Beta\", credit: 1200 }\ntracker.trackScreenView(\"Home\", { customDimensions });\n```\n\n### CustomDimensionsByIndex\n\n-   **See: CustomDimensionsFieldIndexMap**\n-   **See: CustomDimensionsByField**\n\nA dictionary with custom dimensions values and their index keys.\n\n#### Examples\n\n```javascript\nconst customDimensions = { 1: \"Premium\", 3: \"Beta\", 5: 1200 }\ntracker.trackScreenView(\"Home\", { customDimensions });\n```\n\n### CustomDimensionsFieldIndexMap\n\n-   **See: CustomDimensionsFieldIndexMap**\n-   **See: CustomDimensionsByField**\n\nA dictionary describing mapping of field names to indices for custom dimensions.\nThis is an optional object used by the tracker.\n\n#### Examples\n\n```javascript\n// Create something like:\nconst fieldIndexMap = { customerType: 1 };\n// Construct tracker with it:\nconst tracker = new GoogleAnalyticsTracker(\"UA-12345-3\", fieldIndexMap);\n// This allows you to send in customDimensions in the`HitPayload by field name instead of index:\ntracker.trackScreenView(\"Home\", { customDimensions: { customerType: \"Premium\" } });\n// If you do not provide a map, you instead have to send in by index:\ntracker.trackScreenView(\"Home\", { customDimensions: { 1: \"Premium\" } });\n```\n\n### CustomMetrics\n\nA dictionary with custom metric values and their index keys.\n\n#### Examples\n\n```javascript\nconst customMetrics = { 1: 2389, 4: 15000 }\ntracker.trackScreenView(\"Home\", { customMetrics });\n```\n\n### DataLayerEvent\n\nThe Google Tag Manager DataLayerEvent dictionary.\n\nPopulate this event-object with values to push to the DataLayer. The only required property is `event`.\n\n#### Parameters\n\n-   `event` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n#### Examples\n\n```javascript\nconst dataLayerEvent = {\n  event: \"eventName\",\n  pageId: \"/home\"\n};\nGoogleTagManager.pushDataLayerEvent(dataLayerEvent);\n```\n\n### ProductActionEnum\n\nEnhanced Ecommerce ProductActionEnum\n\nUsed by `ProductAction` when describing the type of product action. The possible values (numbers) are:\n\n-   Detail = 1,\n-   Click = 2,\n-   Add = 3,\n-   Remove = 4,\n-   Checkout = 5,\n-   CheckoutOption = 6,\n-   Purchase = 7,\n-   Refund = 8\n\n### Product\n\nEnhanced Ecommerce Product\n\nUsed by `HitPayload` when populating product actions or impressions\n\n#### Parameters\n\n-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `category` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n-   `brand` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n-   `variant` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n-   `price` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Optional)\n-   `couponCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n-   `quantity` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Optional)\n\n#### Examples\n\n```javascript\nconst product = {\n  id: \"P12345\",\n  name: \"Android Warhol T-Shirt\",\n  category: \"Apparel/T-Shirts\",\n  brand: \"Google\",\n  variant: \"Black\",\n  price: 29.2,\n  quantity: 1,\n  couponCode: \"APPARELSALE\"\n};\n```\n\n### ProductAction\n\nEnhanced Ecommerce Product Action\n\nUsed by `HitPayload` when describing a product action\n\n#### Parameters\n\n-   `action` **[ProductActionEnum](#productactionenum)** \n-   `transaction` **[Transaction](#transaction)** (Optional)\n-   `checkoutStep` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Optional)\n-   `checkoutOption` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n-   `productActionList` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n-   `productListSource` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n\n#### Examples\n\n```javascript\nconst productAction = {\n  transaction,\n  action: 7 // Purchase action, see ProductActionEnum\n}\n```\n\n```javascript\nconst productAction = {\n  action: 3 // Add action, see ProductActionEnum\n}\n```\n\n### Transaction\n\nEnhanced Ecommerce Transaction\n\nUsed by `ProductAction` when populating describing a purchase/transaction\n\n#### Parameters\n\n-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `affiliation` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n-   `revenue` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Optional - but not really)\n-   `tax` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Optional)\n-   `shipping` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** (Optional)\n-   `couponCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** (Optional)\n\n#### Examples\n\n```javascript\nconst transaction = {\n  id: \"T12345\",\n  affiliation: \"Google Store - Online\",\n  revenue: 37.39,\n  tax: 2.85,\n  shipping: 5.34,\n  couponCode: \"SUMMER2013\"\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidehub%2Freact-native-google-analytics-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidehub%2Freact-native-google-analytics-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidehub%2Freact-native-google-analytics-bridge/lists"}