on 06-06-2019 2:55 PM
Hi Everyone,
Any one has implemented Google analytics tool on fiori launchpad recently?
I have followed below blog but could not connect with my requirement and generated code through GA.
Blog : https://blogs.sap.com/2017/09/09/google-analytics-for-fiori-launchpad/
Generated code :
<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXX-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-XXXXXX-1'); </script>
Thanks and Regards,
RK
Hi RK,
Please check the path to your files. It seems like it doesn't really know where to look. You probablt need to share your entire component.js file for me to make sense of it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jakob,
Please check this url :https://github.com/rkmishra2703/RK-
Let me know if you are still unable to access.
Thanks and Regards,
RK
I would need to see your code to work that out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply.
Please find below Git space to access the project. Launchpad configuration is same like mentioned in the blog except google id parameter.
z_ga_plugin.zip
https://github.com/rkmishra2703/RK-
Let me know if you need any more details.
Thanks and Regards,
RK
Hi Jakob,
I hope you have got the required code. Let me know in case of any issue.
Auto generated code for my account is given below.
<!– Global site tag (gtag.js) – Google Analytics –>
< script async src=”[a href="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXX-1″>[/a]
< script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());
gtag(‘config’, ‘UA-XXXXXX-1);
< /script>
Thanks and Regards,
RK
This is what we use to track page changes and collect analytics. Add the following on top of your component.js in the FLP plugin
//Boostrap Google Analytics
(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', 'https://www.google-analytics.com/analytics.js', 'ga');
Add the following inside the init function
var sAppID = 'UA-XXXXXXX-' + environmentCodes[window.location.hostname.split('.')[0]];
//Initalize the tracker
ga('create', sAppID, 'auto');
//Called after the plugin is loaded
ga('send', 'pageview', {
// 'page': location.pathname + this.cleanHash(location.hash)
'page': this.cleanHash(location.hash)
});
//Called when the hash is changed
$(window).hashchange(function () {
ga('send', 'pageview', {
// 'page': location.pathname + this.cleanHash(location.hash)
'page': this.cleanHash(location.hash)
});
}.bind(this));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jacob,
Really very thankful to you.
I have implemented code shared by you and added my google account Id "
'UA-XXXXXXX-'" in the code but still it is not working. I am getting below error in the console.
Error :
019-06-12 16:51:38.434020 Cannot create UI5 plugin component: (componentId/appdescrId :com.ctli.flp.ga)
Error: failed to load 'com/XX/flp/ga/Component.js' from /sap/bc/ui5_ui5/sap/z_ga_plugin/~383985DF7E1B91492FAB094D3AFB6614~5/Component.js: SyntaxError: missing ) after argument list properties {"ui5ComponentName":"com.xx.flp.ga","url":"/sap/bc/ui5_ui5/sap/z_ga_plugin/~383985DF7E1B91492FAB094D3AFB6614~5","applicationDependencies":{"url":"/sap/bc/ui5_ui5/sap/z_ga_plugin/~383985DF7E1B91492FAB094D3AFB6614~5","manifestUrl":"/sap/bc/lrep/content/~20190612111306.0878250~/apps/com.XX.flp.ga/app/sap/z_ga_plugin/manifest.appdescr","self":{"name":"com.XX.flp.ga","url":"/sap/bc/ui5_ui5/sap/z_ga_plugin/~383985DF7E1B91492FAB094D3AFB6614~5"},"asyncHints":{"libs":[{"name":"sap.m"},{"name":"sap.ui.core"},{"name":"sap.ui.unified","lazy":true}],"requests":[{"name":"sap.ui.fl.changes","reference":"com.XX.flp.ga.Component"}]},"enabled":true,"name":"com.ctli.flp.ga"}}
This indicates a plugin misconfiguration, see e.g. Note 2316443. - Error: failed to load 'com/XX/flp/ga/Component.js' from /sap/bc/ui5_ui5/sap/z_ga_plugin/~383985DF7E1B91492FAB094D3AFB6614~5/Component.js: SyntaxError: missing ) after argument list
Am I doing any mistake? Please check and let me know.
Thanks and Regards,
RK
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.