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

When firingTriggerId from json export is undefined, getTriggerNames will fail. #1

Open
andreseiji opened this issue Aug 18, 2023 · 0 comments

Comments

@andreseiji
Copy link

Hey @rogersi9, nice code snippet! Saved me some time here to convert the GTM json export to a csv.

I used a json file without any changes exported from GTM, but for some reason there was at least one missing firingTriggerId, instead of an empty array, the export does no set the attribute, therefore throwing the following error on console:

index.js:26 Uncaught TypeError: Cannot read properties of undefined (reading 'forEach')
    at getTriggerNames (index.js:26:9)
    at formatTag (index.js:36:24)
    at index.js:50:24
    at Array.forEach (<anonymous>)
    at gtmToCsv (index.js:49:12)
    at reader.onload (index.js:66:23)

As a quick fix, I change the getTriggerNames function to have an empty array for the ids param, as a default, it seems to have worked just fine:

function getTriggerNames(triggers, ids = [])

Opening the issue so if anyone runs into the same problem, maybe it helps.

Thanks again!

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

1 participant