pgrippi / ember-cli-google-analytics Goto Github PK
View Code? Open in Web Editor NEWEmber CLI addon that adds the Google Analytics tracking code
License: MIT License
Ember CLI addon that adds the Google Analytics tracking code
License: MIT License
We are in a situation where not all of our customers want analytics being tracked so we want to add its as a switchable feature (not requiring a build).
Hi,
I am the creator and maintainer of @onehilltech/ember-cli-google-analytics. It is part of a collection of packages from the ember-cli-google project. I have noticed that this project is no longer being actively maintained. Additionally, it does not support Google Analytics v4. This is the version that Google recommends everyone use now.
Would you consider retiring this project, and recommending people start using @onehilltech/ember-cli-google-analytics.
Just a thought.
Thanks,
At the moment this plugin only explicitly tracks the initial pageview/transition event on app boot. It then relies on GA to try deduce later transitions automatically. From trying it out this seems to be very unreliable.
Solution is to manually track the transitions by adding an observer to your router. E.g:
var Router = Ember.Router.extend({
location: config.locationType,
pageviewToGA: function() {
return ga('send', 'pageview', {
'page': this.get('url'),
'title': this.get('url')
}
}.on('didTransition')
});
But if you add this you end up with a duplicate initial pageview event (one send from html code injection from the addon, and one from the router transition).
Something like this?
ENV.googleAnalytics = {
webPropertyId: 'UA-XXXX-Y'
};
I'm not sure if this is a quite a bug since it may not appear when bootstrapping but it appears that this plugin adds code to the 'head' instead of the 'head-footer'.
When you place code in the 'head' you are injecting it before the included CSS files which causes chrome to not be able to async download the CSS files.
See https://developers.google.com/speed/pagespeed/module/filter-css-above-scripts
https://stackoverflow.com/questions/9271276/is-the-recommendation-to-include-css-before-javascript-invalid
This error came up as a warning in google chrome page speed audit FYI.
When updating to v1.3.0, if ENV.googleAnalytics.tracker
is not specified it won't trigger pageviews.
Fix:
ENV.googleAnalytics = {
webPropertyId: 'UA-XXXXXXXX-1',
tracker : 'analytics.js'
}
As noted in the README, this addon uses contentFor
to inject a <script>...</script>
into the HTML. Content-Security-Policy v2 requires all such tags have a cryptographic signature. See https://www.w3.org/TR/2015/CR-CSP2-20150721/#script-src-hash-usage
Would it be possible to do one of the following?
vendor.js
or its own google-analytics.js
.config
callback, modify config.contentSecurityPolicy['script-src']
(if it exists), adding the signature.The second option requires adding a dependency on a crypto library (build-time concern, not in the generated JS).
In either case, you could move the configuration (UA-XXXX-Y
) into a <meta>
tag in the HTML and pull it off there in the JS.
When running in development or test modes it would be cool if the ga object was created with cookie domain set to none
ga('create', 'UA-XXXX-Y', { 'cookieDomain': 'none' });
This would allow testing when running on localhost
The event didTransition
is never called.
If I change this code:
# mixins/google-pageview.js
export default Ember.Mixin.create({
for this:
# mixins/google-pageview.js
Ember.Router.reopen({
The event didTransition
is starting to been called. But now the parameters page
and title
are undefined
.
Guide is required on how to activate On Page Analytics with the package. If not possible, consider implementing it.
https://support.google.com/analytics/answer/2558867?hl=en&ref_topic=2558810
Should this plugin work with Ember CLI 0.2.5? I added it to my project as described in the readme but I get this error when visiting the page:
Uncaught TypeError: window[globalVariable] is not a function(anonymous function) @ google-pageview.js:18
This is the line(s) which fail: https://github.com/pgrippi/ember-cli-google-analytics/blob/master/app/mixins/google-pageview.js#L16-L18
Used the latest 1.4.0. Is this a known issue?
Our app has information in URLs that is quite sensitive -- such as password-reset tokens, invitation tokens, and internal user IDs. We don't want to send that information to Google. I found two ways in which this information leaks: dl
and dp
.
I've tested this out locally, and the following seems to work about how I would expect, protecting the URLs:
// Prevent analytics.js from sending sensitive URLs in Document Location:
ga('set', 'location', document.baseURI);
router.on('didTransition', function() {
ga('send', 'pageview', {
// send the symbolic route name, not the full URL:
page: '/' + this.get('currentRouteName')
})
});
This has the side-effect of treating a view of /blog-posts/123
and /blog-posts/456
the same. I'm not sure whether everyone would agree, but for our purposes that's an advantage.
Is this possible to add a configuration object to the GA tracker??
We track multiple apps and need tofilter the data per app like below:
ga('send', 'screenview', {
'appName': 'myAppName',
'appId': 'myAppId',
'appVersion': '1.0',
'appInstallerId': 'myInstallerId',
'screenName': 'my overridden screen name'
});
More details https://developers.google.com/analytics/devguides/collection/analyticsjs/screens
Is this possible?
PS: love your package, integrates nicely.
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.