Microsoft Clarity
You can quickly and easily add Microsoft Clarity to your Mattercraft project via the Dependencies Browser.
To set up analytics for your Mattercraft project, you must have a tracking ID. You can find this using Microsoft Clarity's documentation.
Installing Microsoft Clarity
- Open the Dependency Browser and ensure you are in the Recommended tab
- Click on the Analytics category (or find the relevant analytics platform package in the Popular section)
- Find the Microsoft Clarity package and click on it to open the information dialog
- Click on the Install button, which will instantly install the dependency to your project
Using Microsoft Clarity
- Add the Microsoft Clarity component to your Hierarchy by going to
New +
and thenAnalytics
- Click on the analytics component in the Hierarchy and add your tracking ID to the Node Properties panel
- Add a Log Analytics Event Behavior Action to a component you want to get data from
Analytics will not be logged when you preview your experience. To start logging data, your project must first be published.
Using Microsoft Clarity in a script
You can make use of the .logEvent()
method when scripting. Below is an example Custom Behavior which logs a message when a button has been tapped.
// Imports...
interface ConstructionProps {
// Add any constructor props you'd like for your behavior here
}
/**
* @zbehavior
* @zparents three/Object3D/Image
**/
export class LogEvent extends Behavior<Image> {
protected zcomponent = this.getZComponentInstance(Scene);
constructor(contextManager: ContextManager, instance: Image, protected constructorProps: ConstructionProps) {
super(contextManager, instance);
// Target the Analytics component and log an event
this.zcomponent.nodes.MicrosoftClarity.logEvent("Button Tapped!", {'eventCategory': 'Engagement'});
}
dispose() {
// Clean up any resources
// ...
return super.dispose();
}
}
// Uncomment below to run this behavior at design time
// registerBehaviorRunAtDesignTime(LogEvent);
Analytics will not be logged when you preview your experience. To start logging data, your project must first be published.