Tagging - 5 Seconds/50% Scroll Code

I’m looking to add a backend code for a tag to fire after 5 seconds or 50% scroll. Site is below. Does anyone have any suggestions on how to do this on the WIX platform?https://www.837gearvr.com

The code I’m trying to inject is:

Hi,

Assuming you’ve setup the Google Analytics using the steps here: Tracking Events on Your Wix Site with a Google Analytics Property | Help Center | Wix.com, the scroll-depth (percentage) can be set-up using a built-in trigger in Analytics (see: The Scroll Depth Trigger In Google Tag Manager | Simo Ahava's blog , for example).
This is the only viable implementation at the moment, as Code has no support for getting subscribed to the scrolling event of the window.

As for the reporting after 5 seconds - it can be done by setting up a webmethod called from a page/site-level client-code using Javascript’s setTimeout(…). The webmethod will be the backend part reporting to Google Analytics, and will have to store your Google API key for that - since using the API key in the client-side will compromise it (see: Velo: Security Best Practices | Help Center | Wix.com).
Also, you’d need a 3rd party library, such as googleapis, to perform the reporting - see Velo: Working with npm Packages | Help Center | Wix.com for instructions on how to set that up.

Be advised that although your secret key will not be compromised this way, malicious users will still be able to invoke that webmethod and affect the validity of the analytics, if that is a major concern for you.

Hope you’ll find this helpful.

Harel