Create an Easy Opt-In Opt-out Toggle
  • 1 Minute to read

    Create an Easy Opt-In Opt-out Toggle


      Article summary

      Yahoo ConnectID provides multiple mechanisms for users to manage their privacy choices, from industry frameworks to proprietary privacy control portals (learn more by visiting the individual articles for each integration method).

      One method to help your users manage their privacy is our ConnectID toggle. The toggle can be placed within your privacy policy or on the privacy settings page of your website.

      A domain specific opt-out signal for ConnectID is stored in local storage under the key "connectIdOptOut". If the value of connectIdOptOut is "1", the ConnectID JavaScript module will be disabled, preventing ConnectIDs from being generated.

      Publishers may add this HTML snippet to their site to expose the connectIdOptOut signal for their users to toggle.

      <div id="connectid-optout-link"></div>
      <script>
        (function () {
          var optOutLabel = 'Opt-out of connectID';
          var optInLabel = 'Opt-in to connectID';
          function setOptedOut(optedOut) {
            try {
              window.localStorage.setItem('connectIdOptOut', optedOut ? '1' : '0');
              render();
            } catch (e) {}
          }
          function render() {
            try {
              var isOptedOut = window.localStorage.getItem('connectIdOptOut') === '1';
              var a = document.createElement('a');
              a.href = 'javascript:';
              a.title = isOptedOut ? optInLabel : optOutLabel;
              a.appendChild(document.createTextNode(a.title));
              a.addEventListener('click', function eventHandler() {setOptedOut(!isOptedOut)});
              var el = document.getElementById("connectid-optout-link");
              el.firstChild && el.removeChild(el.firstChild);
              el.appendChild(a);
            } catch (e) {}
          }
          render();
        })();
      </script>


      Was this article helpful?