Which utility or UNIX command can help to submit a bulk of event data to Google Universal Analytics? -
Which utility or UNIX command can help to submit a bulk of event data to Google Universal Analytics? -
https://developers.google.com/analytics/devguides/collection/protocol/v1/reference
in link above measurements protocol elaborated. suppose have csv file columns eventname, clientid etc , i'd submit universal analytics system. there unix command, utility or third-party software allow me submit info command line or kind of friendlier ui?
i'm not bash wizard myself there kind of ways improve ( adapted example found on web), here barebone example.
to grouping hits sessions (if applicable) need client id. client id mandatory parameter, if want log each row file new session can utilize random number cid parameter.
however illustration assumes first column in csv file contains parameter can used cid. aware session has max 500 hits (so after need switch cid) , there limit of 20 hits per session replenished @ 2 hits per second, want build delay script.
the illustration assumes csv file semicolon delimiter (can adjusted in ifs variable). assumes there 3 columns, 1 cid, 1 page path, 1 document title. if have more 3 columns lastly value (pagetitle) consume remaining columns (so if there more 3 columns append columns names in line starts "while").
then script builds url (the variables line starts "while" intefied dollar sign in front end of name) , uses wget phone call google tracking server (the server returns gif image wget store - i'm sure there alternative tells wget dismiss content request).
#!/bin/bash uaid="ua-xxxxx-xx" // google analytics business relationship id input=data.cvs // input file name oldifs=$ifs // store default csv delimiter ifs=; // set csv delimiter [ ! -f $input ] && { echo "$input file not found"; exit 99; } // nice error message if input file missing while cid page pagetitle // while there rows in csv read fields wget "www.google-analytics.com/collect?v=1&tid=$uaid&cid=$cid&t=pageview&dp=$page&dt=$pagetitle" // phone call google tracking server done < $input // no more rows ifs=$oldifs // restore default csv delimiter
obviously you'd have create script executable. tested (recent debian/bash) i'm rather sure work. might not efficent though.
unix google-analytics universal-analytics
Comments
Post a Comment