Hey, how can I set up an experiment on a wordpress...
# ask-questions
Hey, how can I set up an experiment on a wordpress site? I have GA4 linked but can’t figure out how to actually make a traffic split. Usually AB testing sites have a javascript snippet to install on your website but I don’t see that in the GrowthBook docs. I can see PHP and Node SDKs but those won’t work on wordpress. I need to be able to do a split URL test where 50% of the audience goes to URL 1, and the other 50% goes to URL 2 then somehow monitor that in growthbook
Hi Robert. While the PHP SDK would probably be your best bet long run, you can also use our JS SDK to achieve front-end only testing. You don't actually need to install via NPM; there is a guide in our "Google Tag Manager and Growthbook" on how to load the SDK in a
tag, which is quite similar to your use case: https://docs.growthbook.io/guide/google-tag-manager-and-growthbook That said, for front-end traffic redirection, it can be a bit tricky to do this in an unbiased (statistically valid) way. This is because your control will have no redirection, but your variant(s) will have a front-end redirection "penalty" which may load more slowly or introduce a flakier user experience. I'd caution being careful to minimize the penalty and/or introduce a similar penalty to your control. To redirect in JS, you could do something like:
Copy code
var result = gb.run({
  key: "my-experiment",
  variations: ["control", "variant"],
  weights: [0.5, 0.5], // Traffic split between the variations
  coverage: 1.0  // What percent of overall traffic to include (0.0 to 1.0)

if (result.value === "variant") {
  window.location.href = "<https://mysite.org/variant-page>"
Hello! I tried running the script you gave me with my own key which is set up in my growth book app, but result.value never changes. It always displays my 0 index variations… Any hint on why my
never changes?