How could I get the bit.ly
link on the page to which bit.ly
link redirects using JavaScript?
I need this for tracking purposes. I have a few bit.ly
links and I would like to track how many times each one of them was clicked in GA.
Thank you.
How could I get the bit.ly
link on the page to which bit.ly
link redirects using JavaScript?
I need this for tracking purposes. I have a few bit.ly
links and I would like to track how many times each one of them was clicked in GA.
Thank you.
Copyright © 2021 Jogjafile Inc.
You could do the following if you insist on working with Javascript.
Send the bit.ly link as a GET parameter with the destination URL. For example: Change this
to
Then in receiver.html use
property to get the list of parameters. Parse this to extract the url that was clicked. One way to do so is to use regular expressions in Javascript. This tutorial is a good starting point https://www.w3schools.com/jsref/jsref_obj_regexp.asp
However, the above technique is a hack and not the correct way to send and receive data across pages. Javascript is a client-side language. A much easier and appropriate way would be to use a server-side language such as PHP to process the sent data.