Has anyone used Google Analytics with Communities before?

There's a cool event called forceCommunity:analyticsInteraction that lets you send custom events etc. https://developer.salesforce.com/docs/component-library/bundle/forceCommunity:analyticsInteraction/specification

Technically it says you can only use it with the following types 'event', 'social', 'exception', 'timing', but I've found it does actually work with the 'pageview' type as well, but it won't accept the custom 'page' attribute that is specified here https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#hitType

It always just sends the current page url.

var analyticsInteraction = 
    hitType : 'pageview',
    page : '/new-page.html'

Does anyone know how I could get it to send a custom page url?

EDIT: We've got a parent Lightning Component that acts as a sort of virtual navigation between different views.

  • but I've found it does actually work with the 'pageview' type as well Where did you find it? Also the docs clearly mention that supported types are event, social, exception, timing. Even if It temporarily works you can't rely on it long term! Dec 11, 2018 at 1:41
  • I found it because I tried it and I could clearly see in Google Analytics that I was getting an extra pageview, but it was still using the same URL, not the one that I specified in the page attribute. Dec 12, 2018 at 2:46


You must log in to answer this question.