Reputation: 1289
I have a website that is being run offline and locally (directly) from a machine. Is it possible to capture analytics data, then upload to google at a later time (when there is an internet connection)?
Can anybody point me in the right direction please?
Upvotes: 1
Views: 201
Reputation: 1529
Based on discussion under original question I set up an experiment.
<script>
// March 18 2016 - 12:10
var actualHitTime = 1458199424000;
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXX-Y', 'auto');
ga('set','page','/timeDelay');
// Time of experiment is 15:44
ga('send', 'pageview', {'&qt': Date.now() - actualHitTime});
</script>
It works :-)
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#qt
From Google:
"Used to collect offline / latent hits. The value represents the time delta (in milliseconds) between when the hit being reported occurred and the time the hit was sent. The value must be greater than or equal to 0. Values greater than four hours may lead to hits not being processed."
Upvotes: 2