Optimize
4K members online now
4K 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

Google Optimize : Single Page Application Set Up

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi All,

 

We have implemented Optimize script via Tag Manager on our website, but we are facing challenges in running an experiment on inner pages as our URL doesn't get changed in the journey after first page load. 

 

For Instance: We have 7 Pages in the journey and first page load URL is https:///www.domainname.com/ABC-Page, and it remains same for all 7 pages in the journey. As Optimize fetch screenshot of page based on the URL and then only experiment can be run. In this case, how we should fetch the screenshot of inner pages or later pages in the Journey as URL doesn't get change.

 

Do we have any provision to use any Java Script type variable or Custom Dimension as parameter to fetch page screenshot or can we use any custom JS or Plug-in ? Please suggest.

 

Regards,

Jeetendra

1 Expert replyverified_user

Google Optimize : Single Page Application Set Up

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Hello Jeetendra, 

 

Yes, you can do a non URL based triggered targeting as well using custom JS.

 

See supporting article - https://support.google.com/360suite/optimize/answer/6301785

and  Rule Types - https://support.google.com/360suite/optimize/answer/6283420

 

Hope it helps. 

 

@community, please feel free to add/suggest/correct.

 

Best

Ruhbir

Google Optimize : Single Page Application Set Up

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hello Jeetendra,

 

Following article will help to track the analytics if you using # https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications#ha...

 

Shall explore the other options and keep you posted

 

Thanks

Satish

Google Optimize : Single Page Application Set Up

Google Employee
# 4
Google Employee

Hi

 

For a single page application you need to use activation events.

 

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

 

Google Optimize has full support for single page apps. You will need to add some additional code in your site that will re-activate experiments any time the page is changed by your framework, (i.e. when you navigate to a different state).

The you could use the regular targeting using URLs.

 

If you can't figure anything better for the framework that you are using, this should work fine on all modern browsers:

 

<script>
if (MutationObserver) {
 new MutationObserver(function(){
   dataLayer.push({'event': 'optimize.activate'});
 }).observe(document.body, {subtree: true, attributes: true, characterData: true});

}
</script>

 

Google Optimize : Single Page Application Set Up

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Great! We will try this fix today and report back! 

Google Optimize : Single Page Application Set Up

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi Dimitris, tnx. We are trying the suggested fix to be able to test multiple pages in our SPA.