I tried to track user activity in my site such as click or mouse over and different kind of events.... Is there any solution to track events even when users are working offline... Can I store them in something like cookie and send them to the server when find active internet connection?
Is that possible?
Thank you
When you create the data source, select Offline event data. For offline events, your imported fields get mapped to Analytics fields automatically. After you upload your data, it can take up to 24 hours for Analytics to make that data available in reports, audiences, and explorations.
Google Ads provides you with a unique ID, called Google Click ID (GCLID), for every click that comes to your website from an ad. To track offline conversions from clicks, you'll save that ID along with whatever lead information you collect from the person who clicked your ad.
Offline Events (or offline conversions) allow you to track when transactions occur at your store and other offline channels after people see or engage with your Facebook ads.
Google Analytics strictly prohibits sending Personally Identifiable Information(PII) instead it allows sending a unique user id. You are not permitted to store any personal information of any individual user like username or IP address in any custom variable but you can store a unique id for that individual user.
Depends on what browser types you're targeting. Are these for HTML5 offline webapps?
If they support ononline
and onoffline
events, you can implement this yourself fairly trivially.
Some potentially workable code, using offline events, native JSON and HTML5 Local Storage:
if(!localStorage.getItem("offlineGA")){
localStorage.setItem("offlineGA","[]");
}
var _ogaq = {
push : function(arr){
if(navigator.onLine || !("onLine" in navigator)){ // if online or if browser doesn't support onLine/offLine detection.
_gaq.push(arr);
}
else{
var stored = JSON.parse(localStorage.getItem("offlineGA"));
stored.push(arr);
localStorage.setItem("offlineGA", JSON.stringify(stored));
}
}
};
$(window).bind("online", function(){ // if you don't have jQuery, you can do window.ononline instead
_gaq.push( JSON.parse(localStorage.getItem("offlineGA")) );
localStorage.setItem("offlineGA","[]"); //empty it
});
Then you would just use _ogaq
as a wrapper for _gaq
.
ie:
_ogaq.push(["_trackEvent","Category", "Action"]);
Another thing to consider is that the time that would get recorded would be the time the data was sent as opposed to collected locally on the device. Fortunately however there is now a way to avoid this being an issue using the measurement protocol and the qt parameter (queue time) it allows you to send the age of the event/view etc.. in milliseconds. I have tried this in the realtime viewer and it does show up at the time recorded as expected.
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#qt
Realise it's an old question but it has been driving me bonkers this weekend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With