Permalink
Browse files

switching to universal analytics

  • Loading branch information...
1 parent bfd1a91 commit 47d1929fd070981efb5b40736af31d005f042e70 @pbackx committed Dec 20, 2013
View
14 ...-ga-tracker/src/main/java/org/vaadin/googleanalytics/tracking/GoogleAnalyticsTracker.java
@@ -26,27 +26,21 @@
*
* @author Sami Ekblad / Marc Englund / Artur Signell
*/
-@JavaScript({ "https://www.google-analytics.com/ga.js", "tracker_extension.js" })
+@JavaScript("tracker_extension.js")
public class GoogleAnalyticsTracker extends AbstractJavaScriptExtension
implements ViewChangeListener {
private static final long serialVersionUID = 1L;
/**
* Instantiate new Google Analytics tracker by id.
- */
- public GoogleAnalyticsTracker() {
- }
-
- /**
- * Instantiate new Google Analytics tracker by id.
*
* @param trackerId
* The tracking id from Google Analytics. Something like
* 'UA-658457-8'.
*/
public GoogleAnalyticsTracker(String trackerId) {
- setTrackerId(trackerId);
+ this(trackerId, null);
}
/**
@@ -60,8 +54,10 @@ public GoogleAnalyticsTracker(String trackerId) {
* 'vaadin.com'.
*/
public GoogleAnalyticsTracker(String trackerId, String domainName) {
- this(trackerId);
+ setTrackerId(trackerId);
setDomainName(domainName);
+
+ callFunction("create", trackerId, domainName);
}
/**
View
26 vaadin-ga-tracker/src/main/java/org/vaadin/googleanalytics/tracking/tracker_extension.js
@@ -1,23 +1,19 @@
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
window.org_vaadin_googleanalytics_tracking_GoogleAnalyticsTracker = function() {
+ this.create = function(trackerId, domainName) {
+ ga('create', trackerId, domainName);
+ }
+
this.track = function(pageId) {
- var state = this.getState();
- var trackerId = state.trackerId;
- var domainName = state.domainName;
- var allowAnchor = state.allowAnchor;
- var pageTracker = window._gat._getTracker(trackerId);
- if (domainName) {
- pageTracker._setDomainName(domainName);
- }
-
- pageTracker._setAllowAnchor(allowAnchor);
-
-
if (pageId) {
- pageTracker._trackPageview(pageId);
+ ga('send', 'pageview', pageId);
} else {
- pageTracker._trackPageview();
+ ga('send', 'pageview');
}
-
};
};

0 comments on commit 47d1929

Please sign in to comment.