All threads / How do I track the clicks to an external url?
Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I track the clicks to an external url?

Amanda asked in Rails

I have a link_to do block that links to an external URL and I would like to keep track of how many times the link was clicked. What would be the best way to do this?

Thanks 😊

Two options that come to mind are:

  1. Have the link go through your Rails app, track the click, and then redirect to the URL (also get to hide the URL this way)
  2. Use Javascript to record the event on click (you could use Google Analytics, Mixpanel, Ahoy, etc)
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 66,029+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.