croct
Learn how to run a snippet once the client-side SDK is ready.
This Twig filter defers a snippet until the client-side SDK has loaded, then runs it with the croct instance available, regardless of the loading mode.
Signature
Apply the filter to a block of JavaScript:
{% apply croct %} // your JavaScript using the croct instance{% endapply %}Example
Here is a basic example of how to use this filter, passing server-side values into the snippet with Twig:
templates/checkout/confirmation.html.twig
{% apply croct %} croct.track('orderPlaced', { order: { orderId: {{ order.id|json_encode|raw }}, total: {{ order.total|json_encode|raw }}, }, });{% endapply %}