0

I have a large website with many links. I would like to see statistics and analytics for each link. I could use Bitly and manually convert every link into a Bitly link, however, this is a tedious process. Is there a way I can automate this?

  • In your own application keep a store of clicks. Then on your links use something like a query string with a referral value (so you know where the user came from), then when your server serves the specific page, increment the count in the database according to the query string. – ApocalypseCalculator Feb 07 '21 at 02:03

1 Answers1

0

You could make a script with a regex, that will fetch all your <a href="">...</a> and replace them by an already defined array of Bitly links.
Apparently, you can use <a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1, taken from this post.

kissu
  • 40,416
  • 14
  • 65
  • 133
  • I understand this. However, I would still need to manually create the Bitly links for each href URL. My question was how do I automate this process of generating tracking links? – NovelPomodoro Feb 10 '21 at 18:07
  • You could automate that with something like [Puppeteer](https://github.com/puppeteer/puppeteer), simulating clicks for you. :D – kissu Feb 10 '21 at 18:08