Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
data-analytics.js
=================

data-analytics.js aims to simplify analytics tagging within a page, by
data-analytics.js aims to simplify analytics tagging within a page by
providing a means of specifying analytics data in purely declarative
`data-analytics` attributes, instead of requiring click handlers to be
written.
Expand Down Expand Up @@ -33,7 +33,7 @@ A field can also be repeated in the DOM heirarchy, with the deeper element overr
<li><a href="dog.jpg" data-analytics="label=Dog"><img src="dog-thumb.jpg" alt="Dog"></a></li>
<li><a href="catsanddogs.pdf" data-analytics="action=Downloaded;label=catsanddogs.pdf">...</a></li>

For event tracking, when a link is clicked data-analytics.js submits the event data to be recorded if
For event tracking, when a link is clicked, data-analytics.js submits the event data to be recorded if:
at least `category`, `action`, and `label` are defined (or inherited) for that link.


Expand All @@ -44,7 +44,7 @@ For sharing analytics over muliple distinct domain names, give the
body tag on both sites a data-analytics attribute with a `domains` field.
This field is a space-separated list of those shared domains.
To also include subdomains, prefix the domain name with a dot.
Subdomains are automatically always included if using Universal
Subdomains are automatically included if using Universal
Analytics (analytics.js).

<!-- eg: -->
Expand Down
4 changes: 2 additions & 2 deletions data-analytics.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** data-analytics.js * @author David Nordlund * © Province of Nova Scotia
* Simplify event recording and cross domain visits for Google Analytics
*/
(function(data_analytics) {
(function (data_analytics) {
function clicked(e) {
var tag = e.target||e.srcElement; (tag.nodeType==1)||(tag = tag.parentNode);
var tag = e.target || e.srcElement; (tag.nodeType == 1) || (tag = tag.parentNode);
var dav = data_analytics.values(tag);
var a, actiontags = {A:1, AREA:1, BUTTON:1}, i, imp;
for (a = tag; a && !(a.tagName in actiontags); a = a.parentNode); //a = ancestor action tag
Expand Down