forceCommunity:routeChange

The system fires the forceCommunity:routeChange event when a page’s URL changes. Custom Lightning components can listen to this system event and handle it as required—for example, for analytics or SEO purposes.
Note

Note

This event is supported in Lightning communities only.

This sample component listens to the system event.
<aura:component implements="forceCommunity:availableForAllPageTypes">
    <aura:attribute name="routeChangeCounter" default="0" type="Integer" required="false"/>
    <aura:handler event="forceCommunity:routeChange" action="{!c.handleRouteChange}"/>
    <h1>Route was changed: {!v.routeChangeCounter} times</h1>
</aura:component>
This client-side controller example handles the system event.
({handleRouteChange : function(component, event, helper) {
    component.set('v.routeChangeCounter', component.get('v.routeChangeCounter') + 1);
    }
})