simpleanalytics / roadmap

File you bugs and feature requests here
24 stars 2 forks source link

In events 2.0, add support for data attributes for automatic tracking #184

Open simpleanalyticsbot opened 4 years ago

simpleanalyticsbot commented 4 years ago

In the current pageview script, you can detect page load and history state change. I propose to attach an event on anything that has a data attribute on it. This way you can add it too links or buttons as a data attribute, and have the SA event be called automatically.

This makes a lot of sense in static site generators that spit out HTML. For me to add JS and track these events feels like something we can automate.

So ideally I could do <button data-sa-event="signup"/>

Not sure if this could be done where it does not collide with existing events and hrefs. Maybe record hrefs and prevent the default. When clicked, call the stored href? Not sure how you handle Angular, Vue, Svelte and React client site SPA nav.

adriaandotcom commented 4 years ago

This seems a great UX for events! As we are updating our JS, we should look at this as well.