Search code examples
spartacus-storefront

How to configure gtm to track OrderPlacedEvent in SAP-Spartacus?


I am using Spartacus 4.2 and i am tracking a bunch of events via GTM. I have configured gtm to track some custom and standard events but when i try to add the OrderPlacedEvent i get the following error:

Type 'TmsConfig' has no properties in common with type 'Config'

The import for OrderPlacedEvent looks like this:

import { OrderPlacedEvent } from '@spartacus/checkout/root';

GTM-Configuration:

    provideConfig({
        tagManager: {
            gtm: {
                dynamicConfiguration: true,
                // TODO: Add events for tracking here
                events: [
                    NavigationEvent,
                    OrderPlacedEvent,
                    //... (custom Events)
                ],
                debug: true,
            },
        },
    } as TmsConfig),

Does anybody know what im doing wrong?


Solution

  • I've faced a similar problem. The reason was that some feature module was referenced before the @spartacus/core and it messed up the Config type augmentation.

    You need to check if some feature module doesn't get imported before @spartacus/core. For instance in app.module.ts.