Google Optimize Test on SPA - Tag firing but test not showing

448 Views Asked by At

I hope you can help me.

I am trying to use Google Optimize with an SPA and am installing via Google Tag Manager. I have followed the instructions, set up a datalayer which fires optimize.activate, so all good so far. I can see the optimize tag is firing, and the basic a/b test is configured to look for that datalayer (rather than pageload). I also have a cookie consent popup on the page.

My issue is that if i load the site and allow cookies, the optimize tag fires as expected but the a/b test does not trigger and there's no _gaexp cookie. If i hit refresh i can see both the a/b test change and the optimize cookie.

What do i need to do to make the optimize test fire once someone has allowed cookies?

Thanks

1

There are 1 best solutions below

3
On

You need to fire optimize.activate after allowed cookies