forceCommunity:analyticsInteraction

Tracks events triggered by custom components in Communities and sends the data to Google Analytics.

For example, you could create a custom button and include the forceCommunity:analyticsInteraction event in the button's client-side controller. Clicking the button sends event data to Google Analytics.

onClick : function(cmp, event, helper) {
    var analyticsInteraction = $A.get("e.forceCommunity:analyticsInteraction");
    analyticsInteraction.setParams({
        hitType : 'event',
        eventCategory : 'Button',
        eventAction : 'click',
        eventLabel : 'Winter Campaign Button',
        eventValue: 200
    });
    analyticsInteraction.fire();
}
Note

Note

  • This event is supported in Lightning communities only. To enable event tracking, add your Google Analytics tracking ID in Settings | Advanced in Community Builder and publish the community.
  • Google Analytics isn’t supported in sandbox environments.

Attribute Name Type Description
hitType String Required. The type of hit. 'event' is the only permitted value.
eventCategory String Required. The type or category of item that was interacted with, such as a button or video.
eventAction String Required. The type of action. For example, for a video player, actions could include play, pause, or share.
eventLabel String Can be used to provide additional information about the event.
eventValue Integer A positive numeric value associated with the event.