-
Notifications
You must be signed in to change notification settings - Fork 14
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
tracking code position #8
Comments
I don't think you can, at the very least not easily and/or without potential side effects. angulartics and the piwik plugin are just a wrapper around the default piwik tracking code, which requires the piwik settings to be defined in a specific way, i.e, as script tags in the HTML. Doing it otherwise would go outside the scope of this plugin, which is to provide easy access and automation to the tracking API. I don't think there's enough benefit in attempting to set the piwik config in angular to merit the effort, specially if the API or code for the config in piwik were to change in the future. The way it is now you can just copy paste it from piwik. But, if you use PHP or any template language like jade to generate the HTML, you can easily use config variables in the backend for the piwik URL and site ID. That's what I do and in my opinion is a cleaner approach that works well, specially if you have multiple environments, the client shouldn't need to know about them. |
I do have multiple environments and I don't want to track code to work in development mode. I will try to figure out another way, like using gulp to add piwik code into html tag. |
@ljcljc then build a condition where to track or not |
@ljcljc I do so in gulp task: ...
var id = ((TIER === 'DEV') || (TIER === 'INTEG')) ? 'INTEG' : 'PROD',
piwikContent = readFileAsync('./configs/templates/piwik-' + id + '.html');
htmlReplaceConfig.piwik = {
src: null,
tpl: piwikContent || ''
};
return gulp.src(srcConfig.src.html)
.pipe(plugins.if(DEBUG, plugins.debug({title: 'BUILD:HTML'})))
.pipe(plugins.plumber(gulpConfig.plumber))
.pipe(plugins.htmlReplace(htmlReplaceConfig, {
keepUnassigned: true
}))
.pipe(plugins.htmlmin(gulpConfig.htmlMin))
.pipe(gulp.dest(srcConfig.dest.html))
.pipe(plugins.if(DEBUG, reload(gulpConfig.reload)));
... in |
I want to get my piwik url from contants defined in angular. Can I put the piwik tracking code inside a controller or app.js config?
The text was updated successfully, but these errors were encountered: