Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Comments

Track download clicks#86

Open
bumi wants to merge 1 commit intomainfrom
track-download
Open

Track download clicks#86
bumi wants to merge 1 commit intomainfrom
track-download

Conversation

@bumi
Copy link
Contributor

@bumi bumi commented Mar 2, 2022

<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<script defer data-domain="getalby.com" src="https://squirrel.getalby.com/js/plausible.js"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can not use window here because of remix (rendering things on the server)
I don't know yet how this would be done in the remix context

function Install({ style }) {

function trackDownload() {
plausible('Download');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not defined here because of the remix context. need to see how to define a window.plausible function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's an example where they detect whether they're on the server and set an empty function as a fallback:
https://remix.run/docs/en/v1/guides/constraints#uselayouteffect

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example also looks relevant, they fix a localstorage call (which has the same problem as window on the server): https://remix.run/docs/en/v1/guides/constraints#rendering-with-browser-only-apis

@jankoegel
Copy link
Contributor

@bumi do you still want to track this in the Rails app?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants