cardinalpath / gas Goto Github PK
View Code? Open in Web Editor NEWGoogle Analytics on Steroids. A Google Analytics implementation with more power features.
License: Other
Google Analytics on Steroids. A Google Analytics implementation with more power features.
License: Other
Just like we do for Youtube
This is an old idea, and I see less and less people usig mailto:
links. Still it could be good to have.
I feel that I don't get the API right. We have 2 problems with the current API.
_trackOutboundLinks
can be added in the future by ga.js and then we have a problem.)_addDomainName
is both a GAS and gaq function. We alter it behaviour and GAS may or may not push that into gaq).So I'd like to prupose a different API, to make it clear what GAS is doing and what is it most likely not touching while sending to ga.js
I first started thinking about it while planning to implement social trackings. Following the consistency with current API _trackOutboundLinks
, _trackDownloads
the most logic choice would be _trackSocial
, but that already exists on ga.js.
So instead of using track Social I have a couple of choices:
_gasSocial
. It's nice because it's namespaced, so we'll never have a clash with g.js functions again. The bad aspect of it is that _gas becomes redundant when you look at the whole call. _gas.push(['_gasSocial']);
_setAutoTrackSocial
, This is more consistent with ga api but we might have problems in the future as well. There an undocumented function incide ga/js called _setAutoTrackOutbound
, I expect that in the future it might replace our _trackOutbound
, and that in the future ga.js might have more functions like that.So my opinion is that we should rename all our plugins for v1.6 keeping backward compatibility. Possibly removing the deprecated names on v2.0.
_trackOutboundLinks
-> _gasOutboundLinks
_trackDownloads
-> _gasDownloads
_trackForms
-> _gasForms
_trackVimeo
-> _gasVimeo
This is a follow up to #52 and #53.
After making the changes suggested in #53, the errors disappeared from the console, but we still get the error screen in Analytics (see screenshot in #52).
At this point it appears we will have to consider dropping GAS, but before doing so I wanted to check if we will lose any of our Analytics history if we switch from GAS to regular GA. Can you comment on this? Thanks for your help on this issue.
Hi, anonymizeIP is not working as expected (aip=1 cannot be found). Seems to be a bug.
Try to find out what kind of social tracking we can do by default
Hi,
Data in analytics seems fine, but receiving various errormessages in chrome developers tools console for the trackforms, maxscroll and outbound links on site www.uretek.nl
Example:
Called method "_gasTrackForms" threw exception.TypeError: Cannot call method 'apply' of undefined
log
N
G.S
G.push
a.(anonymous function)
v
p._execute
(anonymous function)
G.S
G.push
a.(anonymous function)
(anonymous function)
$e
a
(anonymous function)
(anonymous function)
Any suggestions on these errors?
Hi
Since this plugin only handles Video players inserted through iframes, shouldn't it load www.youtube.com/iframe_api instead of www.youtube.com/player_api ??
https://developers.google.com/youtube/iframe_api_reference
https://developers.google.com/youtube/getting_started#player_apis
Right now if you call most of the filters multiple times they may issue multiple event bindings resulting on multiple hits been sent to GA.
We better flag if a tracking already happened and drop that instead.
In addition to that it would be nice to be able to call _trackYotutube or _trackVimeo multiple times to find videos added by ajax. There's a common use case of people using videos inside lightbox.
Hi,
I couldn't find any documentation on this; but google is switching from ga.js to analytics.js (AKA universal analytics). Is this supported by GAS?
Here a code to track Qualaroo survey into GA. For the moment, this code required jQuery. I may need some time to make this code work without jQuery.
/**
* GAS - Google Analytics on Steroids
*
* Track Qualaroo surveys
*
* Copyright 2011, Cardinal Path and Direct Performance
* Licensed under the GPLv3 license.
*
* @author Sébastien Brodeur <[email protected]>
*/
/**
* get the form name for a specific elemet
*
* @param {DOMElemet} el Dom Element.
* @return {String} Form Name or Id.
*/
function getFormName(el) {
while (el && el.nodeName !== 'HTML') {
if (el.nodeName === 'FORM') {break; }
el = el.parentNode;
}
if (el.nodeName === 'FORM') {
return el.name || el.id || 'none';
}
return 'none';
}
var _gasTrackQualaroo = function (opts) {
if (!this._qualarooTracked) {
this._qualarooTracked = true;
} else {
//Oops double tracking detected.
return;
}
// Make sure required attrs are defined or fallback to default
opts['category'] = opts['category'] || 'Qualaroo-';
// Fire when the user submit the survey.
_kiq.push(['eventHandler', 'submit', function () {
// Retrieve Qualaroo survey ID.
surveyId = $("[src*='s3.amazonaws.com/ki.js']").attr("src").match(new RegExp("(id=)([0-9]*)&"))[2];
// For each survey questions...
for (i = 0; i < $("[class*='ki_question']").length; i++) {
// ... get the question text...
question = $("[class*='ki_h1']:eq(" + i + ")").text();
// ... and the selected anwser text
// Check first for radio button answer.
anwser = $("[class*='ki_question']:eq(" + i + ") input:checked[type='radio']").closest("label").text();
// Then for checkbox answer
if (anwser == "" || anwser == null || anwser == undefined) {
anwser = $("[class*='ki_question']:eq(" + i + ") input:checked[type='checkbox']").closest("label").text();
}
// Then for textbox answer(s)
if (anwser == "" || anwser == null || anwser == undefined) {
anwser = $("[class*='ki_question']:eq(" + i + ") textarea").val();
}
// And finaly, score
if (anwser == "" || anwser == null || anwser == undefined) {
anwser = $("[class*='ki_question']:eq(" + i + ") [class*='active'] a").text();
}
// If both data are available, queue a Google Analytics _trackEvent tag.
if (question && anwser) _gas.push(['_trackEvent', opts['category'] + surveyId, question, anwser]);
}
}
};
_gas.push(['_addHook', '_gasTrackQualaroo', _gasTrackQualaroo]);
Firefox and MSIE support printing events beforeprint
and afterprint
. Webkit browsers don't support that.
We could also rewrite the window.print()
function to track an Event. It will only work when the printing event comes from the page and won't work when it comes from the browser.
So I don't see a perfect solution but we should be able to get some nice data out of it. I wonder if it is important or not.
I'd like to hear some opinions on this idea.
track percentages played just like we do for youtube
Recent updates in Youtube API have removed getVideoData, it seems it has never been documented and thus was unsupported
http://www.mailinglistarchive.com/html/[email protected]/2012-08/msg00075.html
it is used here for example:
function _ytStartPool(target) {
if (_ytTimeTriggers && _ytTimeTriggers.length) {
var h = target'getVideoData'['video_id'];
Google Docs: https://support.google.com/analytics/bin/answer.py?hl=en&utm_id=ad&answer=2558867
Willing to implement, just filing an issue to here your thoughts on:
_gas.push(['_gasEnhancedLinkAttribution']);
_gas.push(['_require', 'inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js']);
Many pages dynamically load some of content using Java Script (AJAX). If in dynamically loading content is some outbound links, GAS won't track them. In jQuery is something like .live() to solve this problem. It is possible to improve Outbound link tracker this way?
Thanks.
Say, file downloads, we often track with virtual pageviews:
/virtual/download/readme.pdf
This is because we see these type of files, semantically, as page views, they often open in the browser or some kind of viewer. We apply this to outbound links as well. This comes with the benefit of setting upp great goal funnels, which still is pretty limited with events.
Would be great to be able to alter something along the lines:
_gas.push(['_trackOutboundLinks', {method: 'pageview', path: '/virtual/external-link/'}]);
_gas.push(['_trackOutboundLinks', {method: 'event', category: 'External Link'}]);
can any describe in short how to only use the vimeo tracking part of the code for example? (extract it so to say)
and with universal analytics is preferrable.
I tried several vimeo tracking suggestions but GAS works best out of the box and I did not get others working yet.
we do not need pageview, downloads and etc. since we already have tracking on this.
It can maybe be a good idea to have a general guide for how to 'extract' code parts
The customer in mind already has universal analytics tracking which is why we would like the vimeo tracking to be as well.
These functions are on GAS for a while but I just noticed that they are not documented
Reimplement live tracking. Bublling up this time to find the event.
We also should use live tracking by default on some plugins
Bug / The following mailto Link does not fire an event:
<a href="mailto:?subject=Lesetipp 'UDG-United Digital Group ist die neue Agenturgruppe für digitales Marktmanagement und Kommunikation.'&body=Hallo,%0d%0a%0d%0aich habe auf http://www.udg.de/ einen interessanten Artikel gefunden:%0d%0a">
I suppose this is because there is no "@" in it.
Feels so dirty getting these error messages all over my console :(
_gaq.push processing "_gasMultiDomain" for args: "[mousedown]": ga_debug.js:18
> Called method "_gasMultiDomain" threw exception.TypeError: Cannot call method 'apply' of undefined ga_debug.js:18
_gaq.push processing "_gasTrackOutboundLinks" for args: "[]": ga_debug.js:18
> Called method "_gasTrackOutboundLinks" threw exception.TypeError: Cannot call method 'apply' of undefined
Thoughts?
There is a line that says if the fourth argument of the event is negative, set it to 0. This is bad in this use case: Cart value tracking. People add and remove from the cart. Removing is an event with a negative value. Using the total and average value columns of the events reports you can see the aggregate cart values.
With GAS setting negative values to zero, this tracking is impossible. Should be corrected to allow for negative event values.
It is possible to add new state events for video? There is possibilities of -1 (unstarted), 0 (ended), 1 (playing), 2 (paused), 3 (buffering),5 (video cued) (https://developers.google.com/youtube/iframe_api_reference#Events)
It would be also good if there was difference between starting video (first time of event playing) and playing (other time - after pausing, rewind,..)
Thanks.
Most plugins have hardcoded event categories. There should be a way to change those.
I'd like to put up some better unit tests. We have some tests on QUnit and some manual test pages as well under test now.
The ideal scenario would be to have phantom and casper.js.
Casper.js itself has some very good tests setup that we could use as a base:
https://github.com/n1k0/casperjs
This is in reference to a closed issue: #52
It was closed prematurely, IMO, since the issue was not resolved. Forgive me for being persistent, but I figured that closed issues are not monitored, so it would make sense to post a new issue.
I added the in page analytics plugin, but to no avail. The error continues. I added the Google Analytics debugging extension for Chrome and discovered a few JS errors, which you can see in the attached screenshot.
Any ideas?
Feature / I've seen that an event is fired, when you switch between subdomains. Some clients use internal links with and without www., so every time you switch between "subdomains", an events gets fired. i know this is maybe a rare ocassion but i think it might help if you could control outbound tracking between subdomains, especially on large accounts where you are about to reach hit limits.
Maybe you could do something like this:
_gas.push(['_trackOutboundLinks',{subdomains: '.*']); //fires event for all subdomains
_gas.push(['_trackOutboundLinks',{subdomains: 'www,root,']); //fires event for root and www.
Or like this:
_gas.push(['_trackOutboundLinks',true]); //fires event for all subdomains
_gas.push(['_trackOutboundLinks',false]); //does not fire events between subdomains
Hi -
Using the following GAS script:
var _gas = _gas || [];
_gas.push(['original._setAccount', 'UA-######-#']); //keeping tracking for historical account
_gas.push(['original._setDomainName', '.domain1.org']);
_gas.push(['original._trackPageview']);
_gas.push(['_setAccount', 'UA-######-#']);
_gas.push(['_setAllowLinker', true]);
_gas.push(['_setAllowAnchor', true]);
_gas.push(['_setDomainName', '.domain1.org']);
_gas.push(['_setDomainName', '.domain2.com']);
_gas.push(['_setDomainName', '.domain3.com']);
_gas.push(['_setDomainName', '.domain4.com']);
_gas.push(['_gasMultiDomain', 'click']);
_gas.push(['_trackPageview']);
_gas.push(['_gasTrackForms']);
_gas.push(['_gasTrackOutboundLinks']);
_gas.push(['_gasTrackMaxScroll']);
_gas.push(['_gasTrackDownloads']);
_gas.push(['_gasTrackYoutube', {force: true}]);
_gas.push(['_gasTrackVimeo', {force: true}]);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = '//cdnjs.cloudflare.com/ajax/libs/gas/1.10.1/gas.min.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
On all the cross-tracked domains we're showing visitors but 0 page views and 0% bounces everywhere. Screenshot:
I receive the following error when I add on any link when I track _trackOutboundLinks, _trackDownloads, or _trackMailto
_trackPageview, _trackForms, and _trackMaxScroll seem to work fine.
for (var el = me.srcElement; el.nodeName !== 'HTML';
I am loading jQuery and some other scripts as well, could it be a load timing issue?
Full script I am including:
var _gas = _gas || [];
_gas.push(['_setAccount', 'UA-23636765-1']);
_gas.push(['_setDomainName', '.seedleaf.com']);
_gas.push(['_trackPageview']);
_gas.push(['_trackForms']);
_gas.push(['_trackOutboundLinks']);
_gas.push(['_trackMaxScroll']);
_gas.push(['_trackDownloads']);
_gas.push(['_trackMailto']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = 'javascripts/shared/gas.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
Can there be support for Enhanced Link Attribution? I'm not technical, but I think GAS will need an adaptation? http://support.google.com/analytics/bin/answer.py?hl=en&hlrm=nl&answer=2558867
Can I use _gas.push(['_trackPageview', location.pathname + location.search + location.hash]);
like
_gaq.push(['_trackPageview', location.pathname + location.search + location.hash]);
or is there a better way to track anchor links with GAS?
The official Google documentation suggests a small timeout before tracking outbounds. How does the GAS implementation tackles this workaround navigation?
I want to implement an onclick custom variable set for a few links and was wondering if I can leverage GAS without throwing my own timeout implementation
I'm thinking about switching compilers to uglifyjs.
I'm having problems with closurecompiler mangling too many variables.
I already implemented it in develop. But I wanted to open this issue to get feedback.
It also feels better to me to have a minifier that is open source and based on javascript instead of closure compiler.
Hi
This project emerged recently https://github.com/SDITools/Airlock and allows to use analytics.js without changing the tracking code.
Not tested but could be interesting to activate as an option in _gas ?!
Olivier
The change/submit events don't bubble on ie 6, 7 and 8. So the form Tracking is not working for these browsers on develop.
We have a couple of options here:
While I think 4 is a good idea we don't want to depend on jQuery, so it would fix the problem just for a subset of the users that happen to have jQuery.
I think that for now I'll remove the live Bindings from the Form Tracking. But I'll leave this bug open.
Hey Eduardo -
Wondering how I would "translate" this GATC into GAS (with cross domain tracking for domain1, domain2 on the UA-yyyyyyyy-y account) :
_gaq.push(['o._setAccount', 'UA-xxxxxxxx-x']); // old legacy id retained for data reasons
_gaq.push(['o._trackPageview']);
_gaq.push(['xd._setAccount', 'UA-yyyyyyyy-y']); // id for cross domain tracking
_gaq.push(['xd._setDomainName', 'domain1.com']);
_gaq.push(['xd._addIgnoredRef', 'domain1.com']);
_gaq.push(['xd._setAllowAnchor', true]); // needed on the cross domain tracking only
_gaq.push(['xd._setAllowLinker', true]);
_gaq.push(['xd._trackPageview']);
Would it look like:
_gas.push(['o._setAccount', 'UA-xxxxxxxx-x']);
_gas.push(['o._trackPageview']);
_gas.push(['xd._setAccount', 'UA-yyyyyyyy-y']);
_gas.push(['xd._setAllowAnchor', true]);
_gas.push(['xd._setAllowLinker', true]);
_gas.push(['xd._setDomainName', 'domain1.com']);
_gas.push(['xd._setDomainName', 'domain2.com']);
_gas.push(['xd._setMultiDomain', 'click']);
_gas.push(['xd._trackPageview']);
How to handle addIgnoredRef, since setDomainName is being used to add domains into the cross-domain tracking? Maybe not that important. Is claimed to reduce self-referrals, but may not be needed.
Hello,
Excuse me if this is not the right place for this.
I want to implement this on password protected pdf files. Would that work?
Thanks
Seems like any of the mailto links I have that are using an envelop icon rather than an actual text link aren't firing the tracking event for mailto. Here is the structure of the link:
<a href="mailto:[email protected]"><em class="icon-envelope-alt"> </em></a>
Any reason why this shouldn't work with GAS? Any tips on getting it working?
Mailto links where the address is the link rather than an icon seem to work.
Is there a way to automatically fallback to ga.js if dc.js was blocked?
I followed the example in the readme to add percentages: [25, 50, 75, 90]
to the _gasTrackYoutube
call, but did not see any percentage events in GA. Stepping thru in Firebug showed that lines 209-215 of youtube.js result in opts = {}
and thus opts['percentages'] = []
.
Question / When using the gas MultiTrack feature, does _gas.push(['_setDomainName', 'myothersite.com']); also catch any linked subdomains? Eg, a link to blog.myothersite.com?
Does the first _setDomainName showup as the domain label in GA reports?
Hi Eduardo,
What if we could specify Events/Pageviews for every element on a page we like to track. Say we want to track interactions with jquery accordeon
I am not sure if it makes sense to specify rules within the tracking Code calls (e.g. _gasTrackEverything), as there can be lots of information to it, but I'll leave that up to you, as you are the master ;-). Maybe it could look similar to the _addHook function, but I wonder how more than one rule could be specified then...:
_gas.push(['_gasTrackEverything', '_trackEvent', {
object: 'div',
id: 'track',
page: 'website.com/test.html'
},click]);
_gas.push(['_trackEvent', 'jQuery',id,object]);
Regards,
Sebastian
Hi all,
Is there a way for me to provide a label other than the youtube url? Ideally I'd like to get the label from a data attribute if possible.
I initially tried adding a hook for you tube events as follows but to no avail:
_gas.push(['_addHook', '_gasTrackYoutube', function(options){
// do stuff...
return options_with_different_label;
}]);
I though of using the _trackEvent hook but that'd get a bit ugly with switches on the category and I'm not sure how I could get to the iframe data attributes.
Other than that it looks like the only option would be to add a some kind of hook to the _ytStateChange function that can use the event['target']
to return a different label.
Any help greatly appreciated.
Cheers
Hi, I'd added this code to gas..
_gas.push(['_gasTrackVideo'])
Now, I want that event label in google analytics would be the id of the Video
<video id="foo".....
Is it possible?
Thanks.
We should be able to handle forms for multidomain.
I know that for POST forms we can use _linkByPost.
I need to refresh my memory on what is the best way to track GET forms to setup cross domain. Anyone able to help me here?
If you dynamically add youtube iframes with JS, you cannot add re-add the tracker. This fix makes it work:
if (window['onYouTubePlayerAPIReady']) {
var p;
for (var i = 0; i < youtube_videos.length; i++) {
p = new window['YT']['Player'](youtube_videos[i]);
p.addEventListener('onStateChange', _ytStateChange);
p.addEventListener('onError', _ytError);
}
} else {
window['onYouTubePlayerAPIReady'] = function () {
var p;
for (var i = 0; i < youtube_videos.length; i++) {
p = new window['YT']['Player'](youtube_videos[i]);
p.addEventListener('onStateChange', _ytStateChange);
p.addEventListener('onError', _ytError);
}
};
}
We've been using your script without issue for some weeks now, but just last week, when signing into Analytics, we receive an error message:
There doesn't appear to have been any updates from your end lately, and to my knowledge no one has changed the code on the live site. I verified that the tracking number and domain in your snippet are correct.
The domain in question is www.trustamerica.com.
Do you know what the problem is?
Problems with the current Plugin System:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.