Anecdata aren’t data, and via experimental results, cranberry juice
does not work. It’s often recommended, but it has the same scientific basis as drinking 8 glasses of water or walking 10,000 steps. Which is to say, it’s a marketing ploy.
Cranberry juice is no more effective on UTIs than chicken soup on colds and flus. That is, it can have an impact in part because of the placebo effect (which is substantially more powerful than is currently understood), but it is not because there is any inherent benefit to cranberry juice ("chicken soup" — that is, any clear broth — is at least partially effective because it’s warm liquid fighting diseases which cause dehydration; there’s no medicinal benefit).