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

[gatsby-plugin-google-tagmanager] Custom events, rather than limited to 'gatsby-route-change' #21362

Closed
robmarshallhome opened this issue Feb 11, 2020 · 10 comments · Fixed by #24076
Assignees
Labels
type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement.

Comments

@robmarshallhome
Copy link

The Google Tag Manager plugin currently uses a hardcoded event on a page change: 'gatsby-route-change'.

data.push({ event: `gatsby-route-change` })

To allow more flexibility, it would be great for users to add their own event for this. This could be managed within gatsby-config.js.

If this is a feature that interests you I would be happy to create a PR.

Thanks,
Rpb

@wardpeet
Copy link
Contributor

Hi,

could you explain why this would help your use case? You can add any tag to an event if I'm not mistaken so you should be just fine with gatsby-route-change.

@blainekasten blainekasten added the status: awaiting author response Additional information has been requested from the author label Feb 11, 2020
@github-actions
Copy link

github-actions bot commented Mar 3, 2020

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Mar 3, 2020
@robmarshallhome
Copy link
Author

Hi @wardpeet,

Some clients have specific naming conventions that they like to stick to. Although it is possible to fire events with any named tag event, to ensure consistency for the client it would be great to pass a custom name to this plugin.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Mar 10, 2020
@davidbelow
Copy link
Contributor

davidbelow commented Mar 22, 2020

Hi, @robmarshallhome! If I understand it correctly the gatsby-plugin-google-tagmanager should have a plugin option where you can pass your custom event name like in this example:

// gatsby-config.js

    {
      resolve: "gatsby-plugin-google-tagmanager",
      options: {
        id: "TAG_MANAGER_ID",

        // Include GTM in development.
        // Defaults to false meaning GTM will only be loaded in production.
        includeInDevelopment: false,

        // datalayer to be set before GTM is loaded
        // should be an object or a function that is executed in the browser
        // Defaults to null
        defaultDataLayer: { platform: "gatsby" },

        // Defaults to gatsby-route-change
        routeChangeEventName: "CUSTOM_EVENT_NAME"

        // More options...
      },
    },

I can take a look on this if @wardpeet agrees.

@robmarshallhome
Copy link
Author

@rbelow I have seen that in the options, but if you look at the gatsby-browser.js file, this option is not implemented. So the page change has the default name always.

@davidbelow
Copy link
Contributor

Ok. Seems clear to me. Should we then move forward on this? I would implement it if nobody disagrees.

@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Apr 12, 2020
@marcysutton
Copy link
Contributor

@rbelow we would welcome a PR to make that change, especially since there's an issue here discussing the use case. I'd say go for it!

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Apr 18, 2020
@github-actions
Copy link

github-actions bot commented May 8, 2020

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label May 8, 2020
@davidbelow davidbelow removed the stale? Issue that may be closed soon due to the original author not responding any more. label May 10, 2020
@davidbelow davidbelow self-assigned this May 10, 2020
@davidbelow davidbelow added status: community assigned type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement. and removed status: awaiting author response Additional information has been requested from the author labels May 10, 2020
davidbelow pushed a commit to davidbelow/gatsby that referenced this issue May 13, 2020
@davidbelow davidbelow linked a pull request May 13, 2020 that will close this issue
gatsbybot pushed a commit that referenced this issue May 20, 2020
Co-authored-by: Rubén Below <rbelow@virteal.net>
Co-authored-by: Ward Peeters <ward@coding-tech.com>
@davidbelow
Copy link
Contributor

davidbelow commented May 23, 2020

@robmarshallhome the issue is now closed. I hope you and your clients enjoy the new feature.

Cheers,
Rubén

Follow me on GitHub or Twitter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants