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! – codeyinthecloud Dec 11 '18 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. – Thomas Sesselmann Dec 12 '18 at 2:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.