Best way to add Amplitude analytics to Hugo site

In Hugo’s “JavaScript Building” documentation, it shows how to add a JS file for Hugo to use in building pages. If you use the TypeScript Browser SDK option you mentioned, you’d write an appropriate script invoking the npm package and put that script somewhere in the Hugo project’s appropriate folder for Hugo Pipes to process it. As for the capturing of button presses — and I presume you mean as shown in the SDK’s “Tracking an Event” script example — no, Hugo provides no way to do that, since it only generates static pages up-front and serves no client-side function; so you’d have to write JS (or TS) to do that. Hugo itself works fine with TypeScript.

2 Likes