Google Analytics posts monitoring addon for WordPress - wordpress

I'm assigned to create a WordPress plugin that displays recent visits graph under each post in WordPress. I'm struggling with the authentication of the data and general structure of plugin. My first question would be whats the most efficient way to authenticate with Google API for this kind of task?
I was looking into the AuthSub but i cant understand the concept of next parameter in the query. It should be the landing page after authorization, but how can i make it work dynamically with all the different posts?
In OAuth i'm getting a bit lost in terminology.
Second question is how often should the Google API be queried for the results. I mean is it rational to make smaller request every time visitor opens a page or maybe its rater optimal to download the data for the pages once and keep it in local xml and refresh it on some intervals?
As an idea of the plugin overall structure i was thinking of making a php file which would generate the graph out of the GA feed and would do it so when called from post hook via ajax. This would be controlled by passing parameters of the post to that php file.
Would that structure make sense or there is an easier way to preform the task?
I would really appreciate if someone pointed me in right direction especially in authentication problem.

The most important thing to do first is to lay out your design. You don;t want the user of your site to authenticate on the GA API. Because he doesn't have access to your data. So you'll have to login with your own credentials on the backend. And just cache the metrics you want to display on the screen. So, from the user perspective, there's no way to tell if you're using Google Analytics or any other web analytics product.
Since you're working with Wordpress and you'll need to do the data pull on the backend you probably want to do that using PHP.
You should take a look at this PHP library.
http://code.google.com/p/gapi-google-analytics-php-interface/
Even though it's not google officially supported it's pretty good and you won't have to worry about the process of authentication.
It doesn't make sense to query GA every time the user visits your site. Besides impacting the load heavily the GA API has some latency and GA is not a real time tool. The data freshness on your GA data depends on how much data you get. If you are a small blog it can take 2-4 hours to process the data. If you're a big blog it can take up to 48h. So for that reason I'd query the API every 4 hours or so and just cache the data for all your pages. When you render the page it's just a matter of getting it from the cache/db.
To plot that data there are plenty of options around there. I'd suggest you to start with Google Chart Tools.

Related

Need a better solution than google analytics for data visualization dashboard

I trying to find a better solution than google analytics to create dashboards for visually representing custom data.
My use case is that I need something to track and record custom data that is not passed in through custom web events into google analytics.
I was able to find a hacky solution to the problem initially by running a periodic function over my data on firebase and sending it as custom events to google-analytics. (I mention the approach in this answer. The linked blog post gives further details.)
The problem that I faced was that it wasn't always reliable as although the function did run successfully every day, the data was not shown in the google analytics dashboard.
The data I to visualize is gathered as further insights by writing basic code on existing data
I am aware that it is possible to integrate google analytics for various use cases like even the smallest button click, but I am trying to either send custom events( raised outside of the application by running cron jobs or scheduled functions ) through some API call or maybe directly save and update the data in some other place where there is direct access to visualization
Does anyone know a better solution?
The Google Analytics Measurement Protocol allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers, so you can use it to send your data generate outside your application:
https://developers.google.com/analytics/devguides/collection/protocol/v1

Gathering data from google analitycs to my own admin panel

I'm starting with google analitycs.
Before I'll start implementing this into my pages I'm wondering if I'm able to get informations like average time at site, where my user came from, which devices they are using etc.
I would like to get those information from my VueJS front SPA application by async HTTP GET call and display those there. Is it possible?
If yes I would be very thankful if you provide some links to google API where I can find it or some tutorial.
Since Universal GA you can't access users' origin data outside GA in your application. Before that you had all this juicy information inside a cookie, inside __utma, __utmz etc (more info here).
The information you're asking about (time on site, pages visited, etc) can be retrieved from GA afterwards if you make use of the userid feature.

Google Analytics showing active usage for down site

I have a little domain I have been toying with for a year. I put it up on GitHub Pages and I believe I configured Google Analytics. There was no real content there, surely no visitors, and the site went down for unknown reasons at an unknown time. We do use email on this domain, hosted by Google Apps; this has been up and used continuously.
Now, while resurrecting the site and trying to configure Google Analytics, I logged into Google Analytics and I see months of history. Usage is small but very diverse with hundreds of sessions logged from all over the world, over the past year.
I cannot fathom what produced these data (believing the site to be down for this period, and it never having content anyway), and I am concerned to start using this analytics token out of concern it will continue to report spurious data.
How can I determine the source of these data? How can I zero out the account and get it report true zero usage before I start using it again?
Ryan
There could be someone using your UA-CODE or maybe even you accidently still using that code on another page, luckily, creating a new code is a breeze so you should consider creating a new code for your next project

Separate analytics for each profile page within a single website

There are multiple profiles on my website and each user is managing his/her profile himself. I am trying to find the most efficient way to present analytics of each profile to its owner. Here are 3 ways I found:
Record each and every hit made on a profile page against that profile. This is not just count of hits, this requires to record IP, country, referrer, search terms etc. against each hit. This would require me to manage a huge database as there would be a lot of hits on each page. And a lots of processing on this database. Even if I have to de this, what database is recommended for such use?
Use Google Analytics on each page. But I am not sure that Google Analytics provide an API to fetch Analytics for individual pages.
Use some open source solution like piwik. Again I'm not sure if they provide per page analytics or not.
Please suggest the pros and cons of using each approach.
Update: More explanation - Think of it like a facebook page where each user can see hits on his page. What solution you'd suggest?
For Piwik, you can create a site id for each user, because you are allowed unlimited site ids with Piwik. You can can use a tracker with that user siteid, so when your member logs in, they get data only on their pages. You might also want to look at using custom variables and use the Piwik API to filter data.
Check here for info on multi-tracker: http://piwik.org/docs/javascript-tracking/#toc-multiple-piwik-trackers

ability to capture on what user was doing on the web page

Is there a tool to capture actual user experience on a my website. I would like to capture things like customerid, which button they clicked, information in their cookie, query string etc. etc. etc. Is there a tool that I can plug into my website that would provide this information for a web page and dump into nice columns in sql server table? I would like to be able to …
go through the logs.
Pick a particular log entry
Zoom into that log entry and look into more detailed information like querystring, cookie data etc.
Be able to capture all the information on what user was doing on that page when the exception happened.
Is it possible? Is there a tool out there for this?
Thanks.
This article describes using Google In-Page Analytics to generate heat maps for where users click on your web pages but this is aggregated rather than for specific users. In addition to the normal hits GA records for a page you can also add custom hits based on client-side interactions using a technique similar to tracking outbound links. We used this with the GA Funnel to track progress through a sign-up form.
Having ELMAH installed is unbelievably useful for a wide range of reasons and will be well worth configuring if you haven't already.
I found WebLog Expert to be very handy for analysing the IIS logs at an aggregate level.
I'm not aware of any one product that does all three elements and none specifically well at the per user level.

Resources