Skip to content

sa_event not available in window #19

@alexandrumogic

Description

@alexandrumogic

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions