I’m trying to track members in my affiliate links, I use a program which enables this feature in using ‘EPI’, more info here: Get started with EPI | Adtraction Help Center
Now when clicking on my affiliate link or (button2) the link doesn’t change to contain the EPIs, something that it did before something went wrong.
I don’t understand what’s wrong with my code and I would appreciate it if somebody could give me some insight on why it doesn’t work.
import wixUsers from 'wix-users';
import { currentMember } from 'wix-members';
import wixLocation from 'wix-location';
var org
var name;
$w.onReady(function () {
let userId = wixUsers.currentUser.id
console.log(userId);
$w('#repeater2').onItemReady(($item, itemData, index) => {
currentMember.getMember()
.then((member) => {
const id = member._id;
org = member.contactDetails.customFields["custom.member-organisation-id"].value
name = member.contactDetails.firstName
$item('#button2').link = ` ${itemData.adtractionUrl}&epi=${userId}&epi2=${name}&epi3=${org}&epi4=${member.loginEmail}`
console.log($item('#button2').link);
})
.catch((error) => {
console.error(error);
});
// $item('#button2').link = itemData.adtractionUrl + '&epi=' + userId + '&epi2=' + name + '&epi3=' + org
// $item('#button2').onClick(() => {
// var link = itemData.adtractionUrl + '&epi=' + userId + '&epi2=' + name + '&epi3=' + org
// if (name) {
// wixLocation.to(link)
// }
// })
})
});