I am looking to query Piwik API in real-time to get stats on the current visitor. For example, I have a javascript file that'd I'd like to fetch Piwik API JSON with to get info on the visitor who is using the page which contains the javascript file (referrer, mobile/desktop, location etc.)
As far as I understand Piwik must have this data to generate analytics on per-user basis. My fear is that it might not actually allow querying this info in the way I've described above. If that's the case, what can I do to obtain it from PW? Obviously API method would be better, but if not I'd like to use the same system to make real-time reports as the one I use to generate stats on the groups of the users this particular one belongs to.
According to their API page, the PIWIK Live! widget refreshes every 5 seconds, and displays new visits. For each visitor, you can see:
date
number of actions
time spent on the site
country
browser
operating system
whether the visitor is new or a returning visit
the referrer used to access your site (Search engine & keyword, Campaign,
or Referrer website)
whether the visitor converted a goal
You can query the Live! API Module and the use the Live.getLastVisitsDetails method to get the data you asked about.
Related
I successfully implemented Google Sign-in button where I log in using Gmail accounts from a hosted domain (HD) of mine: with Javascript I retrieve user's data, but the only infos about his/her HD is just the name (by using getHostedDomain()).
So I made a Service Account in order to get more infos about my HD (using Python API): by using HD name, I retrieve groups and members of the HD.
So far so good, but the process of information collection is not one: it is splitted in two different files executed at different times. For now, I sign-in with a Gmail account on a web page and I take note of the HD returned to which the logged user belongs; then I run my Python script in a terminal that examines the given HD name in order to retrieve groups and members.
I'm trying to implement a single execution collector where only a file is executed and possibly only one language is used: the web page is the file I cannot give up since I'd like to offer Google Sign-in, so I'm trying to access other HD infos (besides its name) from the web page with Javascript, without using my other Python script.
Is it possible to retrieve everything only using Javascript?
I think what you are looking for is to retrieve all groups for a domain or the account. Also to retrieve the data you needed for a specific user, you can use the method Users: get.
Say I'm starting a site, refer.com, where I post items on an 'affiliation' basis. When users click on my links, they're directed to the site shop.com. If the user I redirect to shop.com makes a purchase, I need that conversion tracked.
I see two possibilities:
Creating a custom tracking library (probably JavaScript) where I
request URLs from refer.com to transfer information from shop.com. I guess PHP would work too, but reduces compatibility with clients.
I use Google Analytics cross-domain tracking to do this. I don't
want the refer.com GA account to interfere with the shop.com GA account, but as I understand it you can use several accounts on the
same page, giving them different identifiers.
I feel like I'm stuck with a narrow set of possibilities. Do I do both? Neither? I need it to be as easy to implement as possible for the client, while also providing relatively bullet proof tracking. What's the standard today? Affiliation services are everywhere, and this type of cross-domain tracking has to be a very used technique. Is there another preferred method of achieving this that I'm not aware of?
This question might seem highly theoretical. While that may be true, answers with code are highly appreciated too.
I have a way for this to work but it requires both your domains to have the Universal Analytics code installed. This will not work with the older GA code
https://support.google.com/analytics/answer/1032400?hl=en
You can install multiple instances of the Google Analytics tracking code on your web pages to send data to multiple properties in your account.
You can, for example, install multiple instances of the Universal Analytics tracking code (analytics.js) on your web pages but only one instance of the Classic Analytics code (ga.js).
So (provided they have your GA code installed) when you refer to shop.com what you should do is this
Parse your GA cookie. You can get to it by $_COOKIE['_ga']. The cookie holds a string that has four parts, broken up by periods. (i.e. GA1.3.367110421.1357220305). You want those last 2 numbers (in this example 367110421.1357220305)
Pass the parsed cookie data in your referral to shop.com
shop.com should store the parsed cookie in its session
Last but not least, when shop.com has your referral data it should load your GA code and set your sessions up like this
ga('create', 'UA-YOUR-GA-CODE', {'cookieDomain': 'shop.com', 'clientId': 'USERS-PARSED-SESSION'});
What this does is it passes your GA session to their domain. At this point, GA will keep their session going so you can track what happens on shop.com. Any conversion data they pass to their GA code should be passed to your GA as well.
Is it bulletproof? No. You have to trust shop.com to properly retain and show your referrred GA session ID. But I have to use this methodology to keep my sessions between my primary sites and the centralized checkout we use and it preserves my Adwords conversions, etc.
I feel like if you're looking for ease of use for the client, Google Analytics is a pretty solid option. It is a widely used tool, with lots of documentation and active forums for feedback. Also, from my research on the topicit seems that they've got this type of behaviour in mind already.
An alternate that comes to mind is that, when redirected from site A to site B, they should be forced to authenticate on site B. You could then setup an authentication form that is unique to this referral from site A, and will be filtered into your database separately from regular authentications on site B.
Most 3rd party analytics services that rely on client-side tracking (i.e. Javascript tags) are built around the assumption that you want to push data to the third party's servers, and then use their reporting front-end.
For a company with a large data warehouse, there is often a requirement to join the web (or mobile) events data to offline data on a persistent unique user id. From there, the company will have it's data scientist/devs/analysts build custom reports and front end dashboards.
I'm looking for a solution that handles all client-side tracking, but assumes you want to push the data to a local data warehouse. The solution must allow for a persistent unique user id to be associated with each event (unlike Google Analytics). I am NOT concerned with a reporting front end.
EDIT: the real limitation seems to be exporting data at per-event, per-user granularity from an API call, intra-day. Mixpanel allows this level of granularity, but only every 24 hours as a data dump.
edit based on clarification in comments
A couple clarifications: 1. I'm looking to push web event data to my
own servers, not push offline data to Google's Servers. 2. Google does
not allow for export of data at per user id granularity. 3. Mixpanel
does allow for export at per user id granularity, but only every 24
hours as a giant data dump
Here are the 2 that I have seen come up most often in my web analytics adventures:
Piwik is an open source tracking solution that you install and collect data on your own server. The main advantage to this one is that it's free. But it is also really popular and has a robust community.
Alternatively, WebTrends, has a version that can be installed on your own server (Analytics on Premises). Personally I'm not a fan of WebTrends, but I've had some clients swear by it for reasons unknown to me.
When you setup a google analytics profile and you specify the domain, does google make any sort of validation prior of registering a hit?
Does it check that the call comes from the specific domain, based on the key you are provided (ie UA-11580xxxx-xx)?
If I get the above analytics key and put it in another domain, will the hits on that site be registered for the domain for which the key was generated?
Thanks
Sort of.
By default, Google Analytics accepts hits to your account without ever checking where it comes from, so you could register your domain as foo.com, and still forever send traffic from bar.com without any trouble (or from a mobile app, etc).
However, Google provides an optional validation tool that will crawl the page of the website you provide, in order to validate whether or not you installed it correctly. But usage of this tool is optional, and is not a prerequisite for successfully sending and receiving data.
I believe it does. I dynamically generate my Analytics JS code just from the key, and, when I've put the wrong one in, I'm pretty sure the traffic appears to go to the wrong site.
I'll re-test one of my sites to make sure...
When you put the analytics code in the bottom of your HTML(with the key you got from google), first day you don't see anything, because Google is then already counting all visits on your website. after a day you can see result from the previous day.
Let's say I run a site where customers are willing to pay for a page that shows some sort of cool info about them. The whole site is tracked using Google Analytics.
To provide stat tracking for the customers, would it be possible to mine the data from Google Analytics, using the AJAX API?
Are there any show-stoppers I should look out for before attempting this?
Trying to prevent from writing my own stat tracking solution.
Update, a bit more clarification: I'm looking to be able to build a stats page that shows a few stats for a specific url (page views, traffic sources, etc...), not necessarily in real-time. I would cache the page to prevent hitting API rate limits.
There are 2 major impediments: One technological, and one legal-ish. Together, they make using Google Analytics Data Export API an unfit solution.
Technological: Google Analytics Data is not available in Real-Time. Delays in data processing run from 3-4 hours to 24-48 hours. Page-views are processed fasted; things like custom variables often take a day or so). In theory, you could tag each user with a custom variable, and then query against that custom variable for information.
Legal-ish The Google Analytics Terms of Service prohibits you from collecting personally identifiable information. So, you can't use a custom variable that stores their username on your site without violating the Terms of Service. Here's the relevant section.
PRIVACY . You will not (and will not allow any third party to) use the
Service to track or collect personally
identifiable information of Internet
users, nor will You (or will You allow
any third party to) associate any data
gathered from Your website(s) (or such
third parties' website(s)) with any
personally identifying information
from any source as part of Your use
(or such third parties' use) of the
Service. You will have and abide by an
appropriate privacy policy and will
comply with all applicable laws
relating to the collection of
information from visitors to Your
websites. You must post a privacy
policy and that policy must provide
notice of your use of a cookie that
collects anonymous traffic data.
As far as alternatives, it depends on what information you want. You can access their IP address on the server side and use that with a third party tool or a command line call to find out their rough location (much the same way that Google does). You can similarly access their referer on the server side. Much of the information that gets sent to Google actually gets stored in the Analytics cookies (_utm prefixed cookies). There's a wide body of literature on reading these cookies (See: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=how+to+parse+google+analytics+cookies)