Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request/question: trackEvent predefined properties #12

Open
lukasaric opened this issue Sep 23, 2023 · 6 comments
Open

Feature request/question: trackEvent predefined properties #12

lukasaric opened this issue Sep 23, 2023 · 6 comments

Comments

@lukasaric
Copy link

@LouisMazel @michael-bouvy
Currently when I try to use gtm.trackEvent it has some prefined props (event, value etc) already set.

Is there a way to omit all the predefined props and just use the custom ones? (I want to have object that ends up in the datalayer completely purified from those predefined values)

If no, is there a possibility to add this as a feature?

@LouisMazel
Copy link
Contributor

LouisMazel commented Sep 23, 2023

Hi @lukasaric,

This module is a wrapper of @gtm-support/vue-gtm, may be you can ask this feature to the author.

But, I think you can extend the type TrackEventOptions of the @gtm-support/core to add your custom props.

export interface TrackEventOptions {
    [key: string]: any;
    event?: string;
    category?: any;
    action?: any;
    label?: any;
    value?: any;
    noninteraction?: boolean;
}

@lukasaric
Copy link
Author

lukasaric commented Sep 24, 2023

Hi @lukasaric,

This module is a wrapper of @gtm-support/vue-gtm, may be you can ask this feature to the author.

But, I think you can extend the type TrackEventOptions of the @gtm-support/core to add your custom props.

export interface TrackEventOptions {
    [key: string]: any;
    event?: string;
    category?: any;
    action?: any;
    label?: any;
    value?: any;
    noninteraction?: boolean;
}

Hey!

Well, I’s not problem with the types, they are fine (you can add additional custom props). Problem is that even if you add them, these predefined prop values will be still persisted.
e.g:

gtm.trackEvent({ custom: 'test' })
// object in data layer will be: { custom: 'test', event: null, value: null …. }

But thanks anyways, I think I should ask gtm support for this since as you said, this is only a wrapper.

Here's the reason why are there prefined values: https://github.com/gtm-support/core/blob/1ddebc22ade4dc0367a885630bb5689364f7456f/src/gtm-support.ts#L213C13-L213C13

@lukasaric
Copy link
Author

lukasaric commented Sep 24, 2023

@LouisMazel raised a feature request and PR on the gtm-support/core:
gtm-support/core#351 (comment)

After it gets merged and version bumped, then you can bump the version here too! Thanks

@lukasaric
Copy link
Author

@LouisMazel
latest gtm-core release with the new push feature

@LouisMazel
Copy link
Contributor

@michael-bouvy Can you update the dependency and release?

@lukasaric
Copy link
Author

lukasaric commented Sep 28, 2023

@LouisMazel Technically, we don't need to update the dependency (since it's not fixed version => ^2.0.0). It won't hurt, but now the push method is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants