I am trying to collect hits/events from a Google Sheets into Google Analytics. These are the hits I need to collect:
I have to use Measurement Protocol to actually send these data over to Google Analytics.
Is it possible to send these data without having own server, I mean directly from the script editor?
And how can I set up the Google Analytics - do I need to create some custom goals to get the information I need?
I found this script on GitHub:
function sendGAMP(tid, url){
var data = {'v': '1',
'tid': tid, // TrackingID Google Analytics
'cid': Utilities.getUuid(), // ClientID / UserID --> Session.getTemporaryActiveUserKey()
'z': Math.floor(Math.random()*10E7),
't':'pageview',
'dl': url }; var payload = Object.keys(data).map(function(key) {
return encodeURIComponent(key) + '=' + encodeURIComponent(data[key]);
}).join('&');
var options = {'method' : 'POST',
'payload' : payload };UrlFetchApp.fetch('http://www.google-analytics.com/collect', options);
}
I don't need anyone to create me a code or something, I just need a little guidance how I can make this work. I tried to search on internet but I just found a tutorial on how to import Google Analytics to Sheets and not the other way.
Yes, you can do that. You need to use Google Analytics Beacon. If you can embed a simple image (pixel tracker), then you can beacon data to Google Analytics. GA Beacon
If you intend to use this in production for your application, you should deploy your own instance of this service, which will allow you to scale the service up and down to meet your capacity needs, introspect the logs, customize the code, and so on.
Please follow the below link and make it work.
https://mashe.hawksey.info/2014/02/tracking-google-sheet-views-with-google-analytics/
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