Below are some useful code snippets that can be used on pages running GCDC gates to achieve various advanced use-cases. These are intended for JavaScript developers with experience of web development. Some of these make use of our JavaScript API which you should be familiar with.
Force the GCDC script to look for and process new gates
If you're adding gate embed code dynamically to a page, you may need to run the below line of code to have the GCDC script find these and process them.
gcdc("loadGates");
Dynamically inject and trigger a page gate
Include and then invoke the below function passing the gate ID as the only argument. You can use this code to inject and process any type of gate, but it's probably most useful when you want to trigger a page gate in response to some actions that the user has taken.
function triggerPageGate (gateId) { let gateDiv = document.createElement('div'); gateDiv.classList.add('gate-' + gateId); document.body.appendChild(gateDiv); window.gcdc("loadGates"); }