This message was deleted.
# announcements
w
This message was deleted.
h
It looks like you're not setting any user attributes, which are required for test bucketing / randomization. See the docs here which reference attributes in the constructor (you can also use
setAttributes()
): https://docs.growthbook.io/lib/js#step-1-configure-your-app
a
I just want that half of users will see variant 1 and another half variant 2. What attributes I should add ?
h
You need at minimum a consistent
userId
(or
sessionId
for anonymous users) that stays with the user across multiple visits. Does your site make either of those fields available? Or are you using any analytics platform that exposes an id?
a
Finally I'm getting user_id from cookie like this
Copy code
function get_ga_clientid() {
    let cookie = {};
    document.cookie.split(';').forEach(function(el) {
        let splitCookie = el.split('=');
        let key = splitCookie[0].trim();
        let value = splitCookie[1];
        cookie[key] = value;
    });
    return cookie["_ga"].substring(6);
}
h
Ah yes, didn't realize you were using GA at first. That works. There are a few different methods that we outline for getting the userId here: https://docs.growthbook.io/guide/GA4-google-analytics#using-gas-client-id
a
Thanks for that, now I want to get some metrics like how many users clicked on one button or another. In metrics i have some errors. Please help me to fix that
144 Views