Cannot find name 'window'

Question:
Best workaround for Page Code’s lack of access to window.(DOM access). I receive the error “Cannot find name ‘window’”

Product:
Wix Studio

What are you trying to achieve:
I’m trying to submit this to Google

// Google Customer Reviews Opt-in Code
window.renderOptIn = function() {
    window.gapi.load('surveyoptin', function() {
        window.gapi.surveyoptin.render({
            "merchant_id": ********,
            "order_id": orderId,
            "email": customerEmail, 
            "delivery_country": countryCode,
            "estimated_delivery_date": estimatedDeliveryDate,
            "opt_in_style": "BOTTOM_RIGHT_DIALOG"
        });
    });
};

What have you already tried:
Putting my code in Page and Custom code.
I’ve tried a lot of different ways to work around it.

  1. $w
  2. rendered Element
  3. wix-window-frontend Litebox
  4. Others I have since closed the tabs to

Additional information:
I want this code to run onCartCompleted or when the Thank-You page loads.

Have you tried this? It’s different from a Custom Element. Embedding Custom Code on Your Site | Help Center | Wix.com

1 Like

I have. I’ve tried an awful lot. Frontend, backend, page, custom, embed. I just cannot seem to connect the dots from backend to frontend to their api. I’m like a cat eating its tail at this point. I would love these features to be swept in the Sales Channel solution.

BTW, did you know that the Sales Channel Solution feed and the Marketing Channel integration feed have different values? The Solution ensure the color, age, and something else are mapped right. The integration does not. Seems to be the case with Facebook too…

Google Reviews also has an API. You could write a web module to retrieve them on the backend and then display them on the frontend.