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

sa_event not available in window #19

Open
alexandrumogic opened this issue Jul 20, 2023 · 0 comments
Open

sa_event not available in window #19

alexandrumogic opened this issue Jul 20, 2023 · 0 comments

Comments

@alexandrumogic
Copy link

Hi!

I configured the plugin as on documentation, but I am not able to get the sa_event from the window, the auto events works fine.

In gatsby-config.js:

    {
      resolve: "gatsby-plugin-simple-analytics",
      options: {
        trackPageViews: true,
        events: true,
        eventsGlobal: 'sa_event',
      },
    },

I am using "gatsby": "4.15.2".

Tracking event function implementation:

export const trackEvent = (type: EventType, metadata?: Object) => {
    if (window && window.sa_event && metadata != null) {
        return window.sa_event(type, metadata);
    } else if (window && window.sa_event) {
        return window.sa_event(type);
    }

    return null;
  };

What am I doing wrong?

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