Optimize
6.1K members online now
6.1K members online now
Everything you need to know about setting up Optimize including creating your account and container, linking to Google Analytics and how to tag your site.
Guide Me
star_border
Reply

Can I use Optimize in a React application?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Our site is an SPA powered by React. Is there any point in trying to use Optimize? I'm thinking there might be problems when Optimize and React competes for DOM control.

 

If that is the case I'm thinking maybe I can use Optimize to manage the experiments and just flip some state that our SPA can use for switching between versions.

 

Thanks in advance for any pointers what so ever.

1 Expert replyverified_user

Can I use Optimize in a React application?

Google Employee
# 2
Google Employee

Hi Peter

 

You certainly can, Google Optimize has many features for dynamic sites and apps (like custom-activation, re-activation and deactivation).

 

You will need to fire a data layer event after a React update or perhaps you can use mutation observers.

 

The other option that you mention (implement that variants yourself) should also work.

 

See https://support.google.com/360suite/optimize/answer/7008840?hl=en