java - How to get total number of authenticated web hits? -


i using google analytic api in java google data 1 of website google account registered. able total number of hits between 2 specific dates, want retrieve total number of authenticated web hits. not getting proper way data using google analytic.

the function have written getting number of hits is:

private static gadata getwebhitsbymonth(analytics analytics, string profileid) throws ioexception {      return analytics.data().ga().get(profileid, "2013-07-01", currentdate, "ga:hits")           .setdimensions("ga:yearmonth")           .execute(); }  

can give me idea this?

since google analytics has no way of knowing whether or not user authenticated, have tell it. there 2 ways approach sending information google analytics: first (easier) custom dimension, , second (more involved, more useful) using user id feature.

if go route of using custom dimension, you'll have set on tracker object know user logged in. assuming first custom dimension you've made, code might this.

// set user logged in. ga('set', 'dimension1', true); 

now subsequent hits sent ga include value. (note: you'll want set false if user logs out.)

to report on data, can use filter limit returned results authenticated hits. might this: filter=ga:dimension1==true.

the second option use user id feature. user id dimension, , allows track logged in users across multiple devices.

the main catch using user id not allowed send identifiable information (pii), may require bit more development work create user id; however, if you're able that, it's better route go.

here developer guides started implementation: https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -