1

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?

user1391152
  • 1,259
  • 3
  • 13
  • 28
  • If I understand correctly, you are trying to export data from your development (local) account and import it to a production (live) account. If that's the case, see this answer: http://stackoverflow.com/questions/6278914/can-we-move-google-analytics-data-to-other-account – dimitry_n Mar 17 '16 at 16:18
  • Thank you. I'll check it out – user1391152 Mar 17 '16 at 16:28
  • How long is the user offline? Is it less than a few hours or a day when they can be expected to be back online? – Philip Walton Mar 17 '16 at 16:38
  • Its basically for a conference. The idea is that people will use it and it will track data, click etc. Then at the end of the day, the data would be uploaded to google analytics – user1391152 Mar 17 '16 at 16:42
  • If you pipe the data in via the measurement protocol there is a queue time parameter (which I think is what @PhilipWalton is alluding to) that allows you to set an offset from data capture time to reporting time. However that allows only for up to 4 hours delay which might not be enough. https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#qt – Eike Pierstorff Mar 17 '16 at 16:42
  • @EikePierstorff, yes that's what I was referring to. Technically the hit just has to be received before the hits for that day are processed, which is usually before 4am in the timezone of the view. That's where the 4 hours number comes from. It's being conservative. – Philip Walton Mar 17 '16 at 16:52
  • @EikePierstorff and Philip Walton - I think that this time delay is dedicated only for mobile app tracking when you are using dispatch feature. Then is possible to send data up to 4am next day to be processed as day before data. But to be honest, I never tried that on "desktop" analytics. – Jakub Kriz Mar 17 '16 at 18:12
  • @JakubKriz, actually no. I do not think you can set this in the JS tracking code (altough I have never tried it), but it's a valid field in the measurement protocol. – Eike Pierstorff Mar 17 '16 at 18:15
  • @PhilipWalton, thank you, I did not know that. For something business critical I'd use the most conservative estimate in any case, but I guess for the OP's use case it might work. – Eike Pierstorff Mar 17 '16 at 18:16
  • 1
    @JakubKriz you can definitely use it in analytics.js on the web. You just use the ampersand syntax to set the `qt` value in the hit: `ga('send', 'pageview', {'&qt': Date.now() - actualHitTime})` – Philip Walton Mar 17 '16 at 18:48
  • @PhilipWalton thank you. I have to set up some experiments. – Jakub Kriz Mar 18 '16 at 14:38

1 Answers1

2

The experiment

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>

Result

It works :-)

enter image description here

Documentation

https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#qt

Limitations

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."

Jakub Kriz
  • 1,501
  • 2
  • 21
  • 29