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

Google analytics #3944

Closed
informa opened this issue Aug 2, 2018 · 12 comments
Closed

Google analytics #3944

informa opened this issue Aug 2, 2018 · 12 comments

Comments

@informa
Copy link

informa commented Aug 2, 2018

Bug or support request summary

Hi I am wondering how to add google analytics on storybook?

I have added the google analytics script to manager-head.html so it appears in the head which is good.
But because storybook is a one page app google analytics isn't recording the routed url.

Steps to reproduce

Clicking on sub pages or components in the side bar is not being recorded in google analytics.
This is would be really handy to get some statistics on popular components and track user flows.

Please specify which version of Storybook and optionally any affected addons that you're running

    "@storybook/addon-knobs": "3.4.5",
    "@storybook/addon-options": "3.4.5",
    "@storybook/react": "3.4.5",
    "@storybook/storybook-deployer": "2.3.0",

Affected platforms

  • All platforms

Screenshots / Screencast / Code Snippets (Optional)

Added in manager-head.html

  <!-- Analytics -->
  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    ga('create', 'ID', 'auto');
    ga('send', 'pageview');
  </script>
@danielduan
Copy link
Member

you're correct. since we don't actually change the route, only the route query parameters, the analytics code might not track it

If you're interested in helping refactor the router so that the URLs make more sense, we'd be happy to point you in the right direction and get a PR going. It isn't trivial though.

@igor-dv
Copy link
Member

igor-dv commented Aug 3, 2018

It also can be achieved as an addon

@ndelangen
Copy link
Member

I'm currently working on routing too, so hit me up if you're interested in collaborating on it @informa.

@informa
Copy link
Author

informa commented Aug 7, 2018

Not sure if I am going to have time to work on this, but I will hit up my team member who might.
Thank you so much for the comments.

@ndelangen
Copy link
Member

@alexandrebodin is also involved in the routing now, tagging him here too.

@stale
Copy link

stale bot commented Aug 28, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Aug 28, 2018
@ndelangen
Copy link
Member

Would be nice to actually create an addon for this, Anyone on the @storybooks/team who'd want to do it?

@stale stale bot removed the inactive label Sep 6, 2018
@pksunkara
Copy link
Member

I would love to. Writing an addon will get me familiar with the client side code of storybook.

@pksunkara
Copy link
Member

Can you guys link me to the routing issues we need to fix first before the addon can be worked on?

@ndelangen
Copy link
Member

I think the addon would just push to GA on every story change, and detect story changes via channel / api ?

@pksunkara
Copy link
Member

Made an early PR, #4138.

@stale
Copy link

stale bot commented Sep 28, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Sep 28, 2018
@pksunkara pksunkara added the todo label Sep 28, 2018
@stale stale bot removed the inactive label Sep 28, 2018
@issue-sh issue-sh bot removed the todo label Oct 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants