Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Example: Adobe Analytics and Lightning Locker in Aura Sites
Include Adobe Analytics in Your Aura Site
1<script>
2 document.addEventListener('analyticsEvent', function(e) {
3 //add logic here to tell your dataLayer about the event
4 //dataLayer.action = e.detail.action;
5 //dataLayer.label = e.detail.label;
6 //or map payload to an AA library event
7 });
8
9 document.addEventListener('analyticsViewChange', function() {
10 });
11</script>
12<script src="full-url-to-your-adobe-script" async></script>Use Custom Events
1document.dispatchEvent(new CustomEvent('analyticsEvent', {'detail': {action: 'click', label: 'Submitted Case'}}));Implement Additional Events for Aura Components
If Adobe Analytics interacts with an Aura component, you also must implement the forceCommunity:routeChange and aura:locationChange events.
1<aura:component implements="forceCommunity:availableForAllPageTypes">
2 <aura:handler event="forceCommunity:routeChange" action="{!c.handleRouteChange}" />
3</aura:component>1handleRouteChange : function(component, event, helper) {
2 document.dispatchEvent(new Event('analyticsViewChange'));
3}aura:locationChange indicates that the hash part of the URL in the browser's location bar has been modified. However, changing the hash part of a location URL is used only rarely—for example, to implement a tab change in the Tabs component.