Jump to content

eric-seek

Member
  • Posts

    1
  • Joined

  • Last visited

eric-seek's Achievements

Level 1

Level 1 (1/20)

0

Reputation

  1. Hello, I'm in the process of adding Amplitude tracking to our site and ran into a small problem. I would like to add the following behavior to the existing onclick handler of the submission button (in this example the newsletter submission button): const newsletterSubmissionHandler = () => { const eventProperties = { page: window.location.href }; amplitude.track('Form Submitted - Newsletter', eventProperties); } So far I've tried the following code injection without success: const newsletterButton = document.getElementsByClassName("newsletter-form-button")[0]; const newsletterSubmissionHandler = () => { const eventProperties = { page: window.location.href }; amplitude.track('Form Submitted - Newsletter', eventProperties); } addEvent(newsletterButton, "click", newsletterSubmissionHandler); I'm wondering what's proper way to do this? I haven't had much success with searching online since adding onclick behaviors dynamically seems like a niche case.
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.