Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hi,
I would like to ask for suggestion to embed Google Analytics or Microsoft Clarity into ThingWorx.
Is it possible to do it via HTMLTextArea?
Hello @VacuumDecay
Embedding Google Analytics is not a part of ThingWorx Functionality. However, you can do by following the article:
https://www.ptc.com/en/support/article/CS196516
Regards
Bhawna
Hi @bchaudhary ,
Thank you for your reply!
Is there any sample extension that uses Google Analytics? Should I put the Google Analytics snippet in *.runtime.js file?
Can the "renderHtml" method accept "<script>"? For example as below:
this.renderHtml = function () {
// return any HTML you want rendered for your widget
// If you want it to change depending on properties that the user
// has set, you can use this.getProperty(propertyName). In
// this example, we'll just return static HTML
return '<!-- Google tag (gtag.js) --> ' +
' <script async src="https://www.googletagmanager.com/gtag/js?id=G-SSS"></script>' +
' <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag("js", new Date()); gtag("config", "G-SSS"); ' +
' </script>';
};
Hi @VacuumDecay ,
I am not aware of any such extension, but probably it would be wise to search via Google to see if there is anything like this.
Documentation around creating widgets is available here: https://support.ptc.com/help/thingworx/platform/r9/en/index.html#page/ThingWorx/Help/Best_Practices_for_Developing_Applications/visualization_widgets_AddingCustomWidgets.html#
One of the sub nodes in there has the answer to your question.