processing / processing-website

Repository for the processing.org website
https://processing.org
GNU General Public License v2.0
68 stars 94 forks source link

Add Fathom Analytics Event Tracking to Downloads #460

Closed SableRaf closed 1 year ago

SableRaf commented 1 year ago

Problem

We would like to track downloads of Processing for each platform (Linux, macOS (Intel), macOS (Apple Silicon), Raspberry Pi (32-bit), Raspberry Pi (64-bit), Windows) using Fathom Analytics.

Proposed Solution

We can achieve this by adding Fathom's trackGoal method to the event handler for each download button. This method will send an event to Fathom each time a user downloads Processing for a specific platform.

Here are the Fathom event IDs for each platform:

Details

The click handler for the download buttons should be modified to include the Fathom event tracking code. Here's an example of what the handler might look like:

const handleDownload = (platform) => {
  switch (platform) {
    case 'Windows':
      fathom.trackGoal('CIMDWXJV', 0);
      break;
    case 'macOS (Intel)':
      fathom.trackGoal('VQUBVEQR', 0);
      break;
    case 'macOS (Apple Silicon)':
      fathom.trackGoal('IWSPGL5F', 0);
      break;
    case 'Linux':
      fathom.trackGoal('HHYWFK7G', 0);
      break;
    case 'Raspberry Pi (32-bit)':
      fathom.trackGoal('ZKSBBVWD', 0);
      break;
    case 'Raspberry Pi (64-bit)':
      fathom.trackGoal('TXVODVYO', 0);
      break;
    default:
      console.error(`Unsupported platform: ${platform}`);
  }
  // code to start the download goes here
};

In this example, handleDownload should replace the existing click handler for the download buttons. The actual code to start the download, which is not shown in this example, should replace // code to start the download goes here.

This is just an example and may need to be adapted to fit the actual structure and logic of our website.

References

Fathom documentation on creating and using events: https://usefathom.com/docs/features/events

Notes

This issue was partially AI generated and may not be 100% accurate