@@ -114,18 +114,23 @@ export class BrowserInitService extends InitService {
114114 // in pageTrack context. So we add it to page_view events, and remove it after the page view.
115115 // page_view events are fired via view-track.component, and exposes dc.identifier.uri via properties
116116 const dimensionId = this . appConfig . matomo . dimensionId ;
117- this . angulartics2Matomo . eventTrack = function ( action : string , properties ?: any ) {
118- if ( action === 'page_view' ) {
119- if ( properties . dc_identifier ) {
120- ( window as any ) . _paq . push ( [ 'setCustomDimension' , dimensionId , properties . dc_identifier ] ) ;
117+
118+ // Only set up custom dimensions if dimensionId is configured
119+ if ( dimensionId ) {
120+ this . angulartics2Matomo . eventTrack = function ( action : string , properties ?: any ) {
121+ if ( action === 'page_view' ) {
122+ if ( properties . dc_identifier ) {
123+ ( window as any ) . _paq . push ( [ 'setCustomDimension' , dimensionId , properties . dc_identifier ] ) ;
124+ }
121125 }
122- }
123- } ;
124- let pageTrack = this . angulartics2Matomo . pageTrack ;
125- this . angulartics2Matomo . pageTrack = function ( path : string ) {
126- pageTrack . call ( this , path ) ;
127- ( window as any ) . _paq . push ( [ 'deleteCustomDimension' , dimensionId ] ) ;
128- } ;
126+ } ;
127+ let pageTrack = this . angulartics2Matomo . pageTrack ;
128+ this . angulartics2Matomo . pageTrack = function ( path : string ) {
129+ pageTrack . call ( this , path ) ;
130+ ( window as any ) . _paq . push ( [ 'deleteCustomDimension' , dimensionId ] ) ;
131+ } ;
132+ }
133+
129134 this . angulartics2Matomo . startTracking ( ) ;
130135 }
131136
0 commit comments