Three Google Analytics Codes on One Site? - php

I was wondering if it was possible to have two or more sets of Google Analytics tracking codes on one page. There's going to be a single webpage that is accessible through either normal methods (desktop or mobile browser), or accessed through scanning the QR code on the product packaging and being redirected that way.
The client wants three things tracked:
Analytics for the full page (all methods of connection)
Analytics for just those connected via normal methods
Analytics for those connected via QR code
I have already developed a means of differentiating the connection method, and switching the Google provided Javascript for 2 and 3.
So is this possible, to have two analytics codes on one page? I have checked all over, can't find an answer that is to the point.
Thanks in advance

A single analytics will report browser and OS used and the origin of traffic. Hence, there's no reason to use three cookies, three JS files when you can just generate a personalized report with the data you need

Don't use different trackers for this, use custom variables. Splitting it up loses you valuable insight into how different use cases navigate the site.

If anyone is ever looking for this:
http://www.publicinsite.com/qr-codes-google-analytics-track-mobile-devices/
That;s the best bet I think

Related

How to authenticate a WordPress plugin by domain name?

I have a hybrid WordPress plugin that fetches all data using curl from the main server. Let's call it A.
B is the client that requests for data and also can send data to A.
Now every request is encrypted and authenticated using a API access keys.
But the problem here is if I copy the plugin from B to a new client site C, the moment I use the same access keys etc. the plugin starts working.
I want to be able to restrict the access of one API access key to one domain name. How can I attain that?
I'd say to include the allowed host's IP address (B) in your access key administration.
So: when B does a call, you can validate the key and the IP it's calling from.
On A, you can use something like $_SERVER['REMOTE_ADDR'] to test the IP calling the script.
Two downsides: when sites move servers, the plugin will stop working. And of course, people can still spoof their IP, so there is a way to get around this, but at least you make it a lot more complicated and probably not worth the hassle for most cases.
A suggestion by TJHX
Make it part of the license you give your customers. The honest ones will follow it, the dishonest ones will find a way to break your DRM. This is a problem technology can't really solve confidently, especially when with things like wordpress people can just see your code - By TJHX
I have also looked into a lot of options but the mere fact is that the user always has access to the code in the wordpress plugin and can easily make amendments to the CURL request Headers even if you encrypt it.
All we can do it add it in our Licenses.
In my plugin, there are iframes that will be loading the data on the frontend so I am going to accept the domain name when the user buys the plugin and will check the referrers to my iframe to sort this issue out.
Thanks a lot guys for your help.

Facebook page multiple tabs with one app mystery

Please read the question carefully before you answer as it is a bit confusing.
I recently saw that Pagemodo gives the option to have multiple tabs on a single page as many times as you want which they call as "UNLIMITED TABS" in their plan options. So this means that if we want multiple welcome tabs on a page that can be done. Technically you can create only one page tab with one application. To have multiple tabs you will need multiple apps.
Now the question is how is it possible?
Even if i have multiple apps, while showing the page tab i can fetch the data about the tab from a db using "page id" as this is the only thing i have in the signed request. How do they get to know which page it is (ok we can get it from signed request) and which app it is out of those multiple apps that were created so that they render data accordingly?
Be careful your not falling for marketing speak.
Pagemodo likely manages a defined number of apps (which may be a very large number) and is allowing you to install them onto any page you manage giving you in essence unlimited uses.
The backend is all managed via end points for each of the apps and the signed request.
I found how it may be possible.
This is a nice place to get an idea of the problem i came up with:
http://forum.developers.facebook.net/viewtopic.php?id=90792
After thinking about it i came up with the following solution that though you do not have a way to get the application id till you are not authenticated using signed request or any other data provided by facebook. But you can still get it via the page tab url.
So if i have an app with tab url as: http://www.example.com/tab.php, we can pass the app id via http://www.example.com/tab.php?id=APPID
Solves the purpose pretty well.

Sending data to the Google Analytics platform - in a pure PHP page?

I'm building an application, and I'd like to incorporate some stat tracking for each of the pages created. However, these pages are simply redirect pages using header() to different places, depending on what conditions have been met.
Rather then build my own stat tracking platform and incorporate it within PHP, I'd rather send traffic data to the Google Analytics platform. However, as the page exits via a header() alteration, I cannot print the normal Javascript code.
Is there anyway I can still have the page and query string traffic data sent to Google Analytics without using the standard script?
User's browser must make a request to Google's 1-pixel "tracking gif". There is google's solution for mobile web sites, where Javascript is not available. You can see it in the tracking code section of your google analytics settings pages. It is written for PHP. However, this pure-PHP solution just inserts <img> tag into the output. It won't work for you, since you're just making a redirect with HTTP headers.
So, there could be two solutions:
Make the redirect via META tag. Thus, you'll be able to track the redirect with either Javascript or PHP-based analytics code.
Try to fetch that 1x1 GIF from google server-side. However, this will screw lots of things in your Analytics. E.g. originating IP will be wrong, so all demographics will be wrong, you won't be able to pass cookies, etc. It will be most rudimentary tracking at best.
There's an official Google's PHP class "Server-Side Google Analytics PHP Client"
https://code.google.com/p/php-ga/

Live Analytics User data in CMS or Framework

I'm trying to use analytics to determine content being served to visitors from a CMS. As far as I can tell there is no API for Google Analytics that allows you to retrieve a users browsing history.
I understand you can store this into the users session, or roll your own logging of user visits, but I'm more interested in analytics platforms that offer and interface to access this data.
Is anyone aware of an analytics platform that allows you to programmatically retrieve the users data?
The other important aspect would be whether the user data can still be retrieved even if the storing of that data is done asynchronously - which would be needed to keep web app responsive.
In analytics platform you have several solutions. The most common in open source is Piwik http://piwik.org/
It offers an API and js tracking systems : http://piwik.org/docs/javascript-tracking/
You can set this up indirectly in Google Analytics, by using funnels and goals. Set a few predetermined paths of website pages, and have the visitors walking these paths reach a goal.
Have a look at http://www.openwebanalytics.com/. A might be a little bit of overkill for your situation, but if you need a customized need, it should be the right fit. If you're a developer or have access to one then you're set.

Activating google analytics using curl?

I need to execute a google analytics script on a site using curl. What are the reporting features that will be available to me for that curl request ?
To make my question more clearer, suppose i have a website www.abc.com which has analytics code on it and if i connect to www.abc.com from www.xyz.com using curl, in the analytics report of www.abc.com will the request i made using curl show ?
What are the parameters that wont show ? since there is no navigator there wouldnt be screen resolutions, color depth, or any other javascript based features. any other reporting features that wouldn't be available to me ?
I need the following to show up :
user agent (which i will be sending by setting header)
referrer (again which i will be sending by setting header)
source ip address and location (using proxies for different countries)
one issue that Im unsure of is Google's cookies and whether (since i might also be using proxies) these need to be cleared. The ultimate outcome is that I need to be able emulate site traffic as if it is coming from a variety of visitors....
IF the entire thing is not technically possible,is there any other way i can simulate diverse traffic into my google analytics account ?
So, the other answers are right: CURL doesn't execute JS, and there are some methods of automated requests that do.
Other methods to simulate diverse traffic to your account include:
Visit the site manually, and grab the __utm.gif request that Google Analytics generates, and manipulate its pieces so that you can CURL it in conjunction with curling the actual site, so that the GA pageviews are recorded. (ie, alter the hostname, pageview name, timestamp, etc.) You can find the meaning of the values of those parameters here.
Implement a server side GA on your target site.
Use a headless web engine to programmatically crawl sites. PhantomJS is a particularly user-friendly option.
Use a browser screenshot service like BrowserShots to get traffic from distributed locations to visit your site.
Use Amazon's Mechanical Turk to get people to visit the site. You could pay $0.01 per click, and get a large amount of diverse traffic from a large number of sources. (To verify, give them an arbitrary, simple task like asking them "What's the headline on this website?")
You can send events directly to Google Analytics using the Measurement Protocol, creating GET or POST requests directly with the tool of your choice.
See reference here:
https://developers.google.com/analytics/devguides/collection/protocol/v1/reference
No, because Google Analytics is based on Javascript and curl doesn't process HTML or Javascript.
Instead of curl, use a command-line tool that does JavaScript, like HTTPUnit (which includes Rhino). I have heard about WATIR too but never tried.
Those happen to be testing tools, but I guess you can use them to trigger Google Analytics too.

Categories