Using the OptanonWrapper Callback Function


Using the OptanonWrapper Callback Function

In the Testing CDN and the Production CDN in your OneTrust Cookie Consent application, you will notice a script containing the below.

<script type="text/javascript">
    function OptanonWrapper() { }
</script>

This is the OptanonWrapper callback function.

A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.

In the case of the OneTrust CDN, the OptanonWrapper function is called after banner script execution.

You can use the OptanonWrapper function to listen for a user event and determine script behavior based on the user event.

For example, a common use of the the OptanonWrapper function creating the event, OneTrustGroupsUpdated, to push values to the dataLayer after user consent, before page reload or navigation.

<script type="text/javascript">
    function OptanonWrapper()
    {window.dataLayer.push({event:'OneTrustGroupsUpdated'})}
</script>

 

原创文章,作者:254126420,如若转载,请注明出处:https://blog.ytso.com/275611.html

(0)
上一篇 2022年7月20日
下一篇 2022年7月20日

相关推荐

发表回复

登录后才能评论