I have an external bio link on my Instagram business page, i want to detect "which" Instagram users click on link and visited my website.
Is this possible by analyzing referral link or other ways? , and is this even legal?
You cannot detect which users clicked on your Instagram external link.
An external Instagram link looks something like this:
Breaking it down, we can see that there are two GET variables in the query string of the URL:
https://l.instagram.com/ ? u = https://www.example.com/ & e = ATPww3V7arueU2tZJxZn2sop0is5m0U3NkJrH05Fz0nud9ENOn38ULgxXDwDvUMwCGDzDqaNXEHn7uzk
Instagram refers to this link as
external_url_linkshimmed in the JSON data that can be found stored in
window._sharedData (web browser).
uparameter most likely stands for
URLand simply stores the external URL that was added to your profile.
eparameter most likely stands for
eventand stores tracking data that Instagram uses for analytics. This value always appears to be 80 characters, and it changes every time someone visits the profile. This value is probably the result of a hash function.
None of this data will allow a user to track who clicked the link, so you cannot use
document.referrer (client-side) or
$_SERVER['HTTP_REFERER'] (server-side) to determine the identity of another user.
If this was possible (which it is not) it would be a major privacy shortcoming of Instagram.
I do not think it is possible to determine which Instagram user visited your page from an Instagram link. In order to get this data, you would need approval from Instagram (which would most likely come from their API). Most API services may allow you to find out a user's username, but this generally requires that the user gives you permission to know who they are (example: signing in).
You can use http_referer in PHP to determine where a user came from, but this requires that a user came from an HTTP address as http_referer does not work with HTTPS.