Hi Wix Community and friends,
I want to change the URL button. If users are from Google, the URL should be website.com?track=ABC. If users are from Facebook, the URL should be website.com?track=XYZ.
How can I do this?
Product:
Which editor or feature is your question most relevant to?
Wix Editor.
How do you check where the users are from before setting the button?
I can do it based on using javascript and gettting document.referrer.
Then assuming you save the referrer, letâs say to a variable named âreferrerâ
$w.onReady(() => {
$w('#button').link = 'website.com?track=' + referrer
})
2 Likes
You can actually retrieve the referrer using the Velo Wix Frontend API https://dev.wix.com/docs/velo/api-reference/wix-window-frontend/referrer
So the code would look like:
import wixWindowFrontend from âwix-window-frontendâ;
let referrer = wixWindowFrontend.referrer;
$w.onReady(() => {
$w(â#buttonâ).link = âwebsite.com?track=â + referrer
})
1 Like