Plan availability: For VoC tools (Surveys): Available on VoC Growth plan.
For Experience Analytics tools (Filters): Available on Contentsquare Growth plan.
For Experience Analytics tools (Filters): Available on Contentsquare Growth plan.
Plugin setup
A variant of an Amplitude Destination Plugin is required to forward events to Contentsquare. Below is a template of a Destination Plugin tailored for Contentsquare. It creates an instance of the Contentsquare tag and forwards tracked events from Amplitude's SDK. This template is customizable for any needs.
import { BrowserConfig, DestinationPlugin, Event, PluginType, Result } from '@amplitude/analytics-types';
import { default as hj } from '@hotjar/browser';
export class HotjarPlugin implements DestinationPlugin {
name = 'hotjar';
type = PluginType.DESTINATION as const;
siteId: number;
hotjarVersion: number;
constructor(siteId: number, hotjarVersion: number) {
this.siteId = siteId;
this.hotjarVersion = hotjarVersion;
}
async setup(): Promise<void> {
hj.init(this.siteId, this.hotjarVersion);
}
async execute(event: Event): Promise<Result> {
if (event.event_type === '$identify') {
const { user_id, device_id, user_properties } = event;
const hotjarId = user_id || device_id || '';
hj.identify(hotjarId, user_properties || {});
} else {
hj.event(event.event_type);
}
return {
code: 0,
event: event,
message: 'Event forwarded to Hotjar API',
};
}
}
Amplitude plugin usage
Amplitude plugin usage Inside the app's code, the plugin may then be imported and added to the Amplitude SDK instance.
import * as amplitude from '@amplitude/analytics-browser';
import { HotjarPlugin } from './HotjarPlugin';
amplitude.init(AMPLITUDE_API_KEY);
amplitude.add(new HotjarPlugin(HOTJAR_SIDE_ID, HOTJAR_VERSION));
amplitude.logEvent('open app');