Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change google analytics interface #521

Closed
wants to merge 27 commits into from
Closed

change google analytics interface #521

wants to merge 27 commits into from

Conversation

rdwallis
Copy link
Contributor

@rdwallis rdwallis commented Jul 9, 2014

Edit: wiki on how to use universal analytics:

https://github.com/ArcBees/GWTP/wiki/Universal-Analytics


This is a related to my post at https://groups.google.com/forum/?fromgroups#!topic/gwt-platform/0cfnA9om3DM

It is a breaking change so needs thorough review before being accepted.

I removed the binding from default module since you now have to bind userAgent at the same time. I think it might be good to add a separate analytics gin module so that analaytics, navigation tracker & UA can be installed all at once.

I moved the GAAccount annotation to the google analytics folder because I think it's a mistake to put all annotations in the same package just because they're annotations. GAAccount.java is much more related to GoogleAnalytics.java than it is to DefaultPlace.java

Edit: Breaking change is that the init method is removed, and googleanalytics is no longer bound by default module. Also this code is completely untested. I'm working on a new project which I'm only adding Universal Analytics to, so someone using the old version of analytics needs to test if everything still works.

@christiangoudreau
Copy link
Member

I agree, we should have separate gin module for that

}

private final Class<? extends PlaceManager> placeManagerClass;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, line 64 could be removed a swell

@christiangoudreau
Copy link
Member

Could you document the breaking change in the description of the review?

@rdwallis
Copy link
Contributor Author

rdwallis commented Jul 9, 2014

Added the breaking change info to description.

My workspace has partial work on Universal Analytics in it so it's a bit of a pain to commit minor fixes to this branch at the moment. Maybe wait a day or two and I'll submit a pull with UA support. (Or just continue on this branch)

This code still needs to be reviewed though. I need to know if the init method can be removed or if the current code loads GA like that for a reason.

@christiangoudreau
Copy link
Member

The init method add the script to the html page asynchronously. This method isn't perfect. For exemple, there's no way to know when the script will be loaded and it can happen that GA isn't loaded when attempting a track event too soon.

@rdwallis
Copy link
Contributor Author

rdwallis commented Jul 9, 2014

Ok I don't think the init method is blocking because it just sets up an empty array and then adds an async script to the header. Events tracked before the ga.js loads are pushed to the array until everything's ready.

It might block on older browsers that don't support async but I don't think that's a major concern.

@christiangoudreau
Copy link
Member

I don't think as well.

@christiangoudreau
Copy link
Member

This doesn't seem to be breaking that much. In the sense that most people use the GoogleAnalyticTracker which use init() in turn. You already made the change to that class as well.

@rdwallis
Copy link
Contributor Author

Ok, so google analytics only updates it's data after 24 hours so I haven't been able to verify that this works at all. But this patch should make it possible to use universal analytics. I'll see if I can work out how to add a wiki page for it now.

@rdwallis
Copy link
Contributor Author

wiki on how to use universal analytics:

https://github.com/ArcBees/GWTP/wiki/Universal-Analytics

@rdwallis
Copy link
Contributor Author

Just tested and this doesn't actually work yet. Working on fix

if ($wnd.console) {
$wnd.console.log("uaNative: "+ params);
}
$wnd.__ua.apply($wnd.__ua, params);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call to apply is having no effect. Can someone good with Javascript tell me what I've done wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params will be an array which will log to the console: eg: ["send","pageview",{"page":"/library"}]

In my code when I call $wnd.__ua.apply with null, $wnd or this as the first param I see no network activity.

But when I go to the console on a live page and type window.__ua.apply(null, ["send","pageview",{"page":"/library"}]) it works perfectly.

No idea why the same command doesn't work from jsni.

bind(GoogleAnalyticsNavigationTracker.class).asEagerSingleton();
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm 79

@rdwallis
Copy link
Contributor Author

I'm happy with this code and have started using it in production. Let me know if there are outstanding issues preventing merging.

@christiangoudreau
Copy link
Member

It'll get picked up by the team today or tomorrow. Since it is a big change, I prefer letting it be reviewed thoroughly.

Also, we started to extract everything that is relation to Google Analytic in another open source project and we may move this code there.

https://github.com/ArcBees/universal-analytics

@christiangoudreau
Copy link
Member

Well, move is a big word. But more likely remove it in 2.0, deprecate it in the meanwhile and suggest to use the other one. (I do not want to create a release of GWTP when changes are only needed in Google Analytics)

@rdwallis
Copy link
Contributor Author

Ok I wasn't aware of the other project. 100% agree that analytics should be separated out of gwtp into its own project.

Even with all this code there are large parts of universal analytics API that I've ignored like the ecommerce plugin and tasks. It's going to be a huge effort to get full coverage.

@rdwallis
Copy link
Contributor Author

I've moved development on this to a new project: https://github.com/rdwallis/gwt-universal-analytics

I generated most of the code directly from the universal analytics api so it should support 100% of the core api.

Anyway I recommend using the new project instead of this pull request. So feel free to close this issue without merging.

@christiangoudreau
Copy link
Member

We also did: https://github.com/ArcBees/universal-analytics

Not in PR right now, but used in GAE-Studio already. This library also
support the measurement api on the server side.

On Tue, Jul 15, 2014 at 10:21 AM, Richard Wallis notifications@github.com
wrote:

I've moved development on this to a new project:
https://github.com/rdwallis/gwt-universal-analytics

I generated most of the code directly from the universal analytics api so
it should support 100% of the core api.

Anyway I recommend using the new project instead of this pull request. So
feel free to close this issue without merging.


Reply to this email directly or view it on GitHub
#521 (comment).

Christian Goudreau | CEO - Président
M: 1.877.635.1585 | S: christian.goudreau
ArcBees http://www.arcbees.com | Blog http://blog.arcbees.com | Facebook
https://www.facebook.com/QueenOfTheBees | LinkedIn
http://www.linkedin.com/company/arcbees

@christiangoudreau
Copy link
Member

We'll be crediting you the contribution and linking your Github project. This library will become official into the Arcbees products eventually.

@rdwallis
Copy link
Contributor Author

https://github.com/rdwallis/gwt-universal-analytics now supports server calls via the measurement api.

It'll automatically fill out required fields for you, so you use the server with exactly the same interface as on the client, no extra setup needed.

Closing this issue, and I'll continue discussion at the arcbees universal-analytics project.

@rdwallis rdwallis closed this Jul 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants