{"_id":"570d6d06e2a0b40e0077aa7f","__v":1,"category":{"_id":"56d1f33900a2a70b00b36595","project":"5526c95cf69851170038b48f","version":"56d1f33700a2a70b00b3658e","__v":1,"pages":["56d1f34000a2a70b00b365ee","56d1f34000a2a70b00b365ef","56d1f34000a2a70b00b365f0","56d1f34000a2a70b00b365f1","56d1f34000a2a70b00b365f2","56d1f34000a2a70b00b365f3","56d1f34000a2a70b00b365f4","56d1f34000a2a70b00b365f5"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-10T15:44:07.282Z","from_sync":false,"order":5,"slug":"ionic-analytics","title":"Ionic Analytics"},"project":"5526c95cf69851170038b48f","user":"5528291960c60f230003fb2c","parentDoc":null,"version":{"_id":"56d1f33700a2a70b00b3658e","project":"5526c95cf69851170038b48f","__v":2,"createdAt":"2016-02-27T19:04:23.946Z","releaseDate":"2016-02-27T19:04:23.946Z","categories":["56d1f33900a2a70b00b3658f","56d1f33900a2a70b00b36590","56d1f33900a2a70b00b36591","56d1f33900a2a70b00b36592","56d1f33900a2a70b00b36593","56d1f33900a2a70b00b36594","56d1f33900a2a70b00b36595","56d1f33900a2a70b00b36596","56d1f33900a2a70b00b36597","56d1f33900a2a70b00b36598","56d1f33900a2a70b00b36599","56d1f33900a2a70b00b3659a","571f9497ada30c34003b7cee"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"beta","version_clean":"2.0.0-beta","version":"2.0.0-beta"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-12T21:47:50.655Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"Event objects are sent through the Internet to the storage backend in batches every two minutes, instead of immediately after the event occurs. This conserves battery life by reducing the number of network requests made. \n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Local Storage\",\n  \"body\": \"Analytics queues events in local storage so that data is not lost when the user closes the app. The storage keys are prefixed with \\\"ionic_analytics\\\", so there is not much risk of namespace conflict. However, be advised that calling localStorage.clear() in your app may lead to the loss of event data.\"\n}\n[/block]\n## Configuring the dispatch interval\n\nBy default, events are sent across the network every 30 seconds. It is possible to configure this interval by setting **$ionicAnalytics.dispatchInterval**. Use a dispatch interval of 0 to disable event queuing and dispatch all events immediately.\n\nIncreasing the dispatch interval conserves battery life. A lower dispatch interval will make event reporting more responsive and cut down on the number of events delayed due to the user closing the app before events are dispatched. (In this case events will still be sent the next time the user opens the app.) \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"console.log($ionicAnalytics.dispatchInterval); // 30\\n\\n// Dispatch events immediately (battery-intensive)\\n$ionicAnalytics.setDispatchInterval(0);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"event-batching","type":"basic","title":"Event Batching"}
Event objects are sent through the Internet to the storage backend in batches every two minutes, instead of immediately after the event occurs. This conserves battery life by reducing the number of network requests made. [block:callout] { "type": "warning", "title": "Local Storage", "body": "Analytics queues events in local storage so that data is not lost when the user closes the app. The storage keys are prefixed with \"ionic_analytics\", so there is not much risk of namespace conflict. However, be advised that calling localStorage.clear() in your app may lead to the loss of event data." } [/block] ## Configuring the dispatch interval By default, events are sent across the network every 30 seconds. It is possible to configure this interval by setting **$ionicAnalytics.dispatchInterval**. Use a dispatch interval of 0 to disable event queuing and dispatch all events immediately. Increasing the dispatch interval conserves battery life. A lower dispatch interval will make event reporting more responsive and cut down on the number of events delayed due to the user closing the app before events are dispatched. (In this case events will still be sent the next time the user opens the app.) [block:code] { "codes": [ { "code": "console.log($ionicAnalytics.dispatchInterval); // 30\n\n// Dispatch events immediately (battery-intensive)\n$ionicAnalytics.setDispatchInterval(0);", "language": "javascript" } ] } [/block]