If you've deployed the FunnelEnvy snippet synchronously in the <head> of your site, and before the Optimizely snippet, FunnelEnvy's native sync with Optimizely Audiences will Just Work (as detailed in this article).

However, if you've deployed the FunnelEnvy snippet asynchronously (e.g. via Google Tag Manager), or after the Optimizely snippet, you'll have to take further steps to use a Marketo audience.

Since Optimizely will execute, and evaluate audience conditions, before the FunnelEnvy snippet executes, it will fail to correctly identify visitors in your Marketo audience. The solution to this involves creating an Optimizely Page with Polling Activation. You'll need to add custom code so the Page activates after the FunnelEnvy snippet runs, and only if the visitor is in the audience of interest.

In Optimizely, create a new Page and set the target URL(s). Under Activation Mode, choose "Polling". Paste the following code:

function pollingFn() {
    return window.optimizely.feDone &&
      window.optimizely.feDone === true &&
      window.dataLayer.some(function (item) {
      return item.event &&
        item.event == 'backstage.updatedAudiences' &&
        item.backstage &&
        item.backstage.audiences &&
        item.backstage.audiences[/* TODO ADD STRING */];

In the second-to-last line, where you see [/* TODO ADD STRING */], you'll need to add a string that corresponds to the name of your Marketo Audience. To generate this string, click the Audience:

Then note the last part of the URL in your browser's address bar:

In this example, the last line of Callback Activation code would look like this:


That's it! You can now launch an Optimizely experiment targeted to that Page, no matter how you've deployed the FunnelEnvy snippet.