Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter JJHZ

    (@rickytf)

    Ok so far I have te following code:

    <!-- Begin comScore Tag -->
    <script>
                var _comscore = _comscore || [];
                document.addEventListener("DOMContentLoaded", function() {
    
                    var TagComscore = {
                        pushData: function(cs_ucfr) {
                            var data = {
                                c1: "2",
                                c2: "XXXXXX",
                                cs_ucfr: cs_ucfr
                            };
                            _comscore.push(data);
                            TagComscore.addScripts();
                        },
    
                        addScripts: function() {
                            (function() {
                                var s = document.createElement("script"),
                                    el = document.getElementsByTagName("script")[0];
                                s.async = true;
                                s.src = "https://sb.scorecardresearch.com/cs/XXXXXXX/beacon.js";
                                el.parentNode.insertBefore(s, el);
                            })();
                        },
    
                        run: function() {
                            console.log("Comscore RUN");
                            if (typeof window.__tcfapi !== 'undefined') {
    							
                                window.__tcfapi('ping', 2, function(pingData) { 
                                    //console.log("Comscore PING");
                                    window.__tcfapi('getTCData', 2, function(tcData, success) {
    										
                                        //console.log('COMSCORE - QUANTCAST V2 cmp responded:', tcData, success);
                                        if( tcData.vendor.consents.hasOwnProperty('77') && success) {
    										window.__tcfapi('addEventListener', 2, function(tcData, Success) { 
     										if (Success) {
       											if (tcData.eventStatus == 'useractioncomplete' || tcData.eventStatus == 'tcloaded') {		
                                            if(tcData.vendor.consents[77]) {
                                                console.log("Comscore: 1");
                                                TagComscore.pushData('1');
                                            } else {
                                                console.log("Comscore: 0");
                                                TagComscore.pushData('0');
                                            }
    									}}});
                                        }
    									 else {
                                            console.log("Comscore: EMPTY");
                                            TagComscore.pushData('');
                                        }	 								
                                    });
                                });
                            } else {
                                TagComscore.pushData('');
                                console.log("Comscore: EMPTY - window.__tcfapi == 'undefined' ");
                            }
                        }
                    };
                    //Run COMSCORE
                    TagComscore.run();
                });
               
            </script>
             <noscript>
                <img src="https://sb.scorecardresearch.com/p?c1=2&c2=XXXXXXX&cv=2.0&cj=1" />
            </noscript>
            <!-- End comScore Tag -->

    And it works fine appending the parameter cs_ucfr and values 1 or empty, but doesn’t work when user opt out (cs_ucfr=0), that value never appends to cs_ucfr.

    Can anyone help me with this? Thanks

    • This reply was modified 4 years, 4 months ago by JJHZ.
Viewing 1 replies (of 1 total)