How to enable & Disable Track Address Bar Engagement (Sharing Analytics) feature in WordPress

Follow

In 2 ways we can achieve this behavior. By adding below code in your WordPress Instance.  

Solution 1:

To implement po.st code in your main index(home) page alone, please follow the below code snippet in "footer" page of your theme.

<?php 
$homUrl=get_home_url();
$cur_url=home_url( $wp->request );
if($cur_url!=$homUrl){ ?>
<script type="text/javascript">
      //              DO NOT IMPLEMENT                //  
      //      this code through the following        //
      //                                              //
      //  Floodlight Pixel Manager                  //
      //  DCM Pixel Manager                          //
      //  Any system that places code in an iframe  //
        (function () {
            var s = document.createElement('script');
            s.type = 'text/javascript';
            s.async = true;
            s.src = ('https:' == document.location.protocol ? 'https://s' : 'http://i')
              + '.po.st/static/v4/post-widget.js#publisherKey=test';
            var x = document.getElementsByTagName('script')[0];
            x.parentNode.insertBefore(s, x);
        })();      
    </script>
<?php } ?>

Note: We validated above code snippet in generic wordpress version 5.1 using free theme . we are using "publisherkey" value as "test" - Use actual value in it while you implement in live environment.

Solution 2: 

To Enable tracking add this below code snippet:

<script type="text/javascript">
      //              DO NOT IMPLEMENT                // 
      //      this code through the following        //
      //                                              //
      //  Floodlight Pixel Manager                  //
      //  DCM Pixel Manager                          //
      //  Any system that places code in an iframe  //
        (function () {
            var s = document.createElement('script');
            s.type = 'text/javascript';
            s.async = true;
            s.src = ('https:' == document.location.protocol ? 'https://s' : 'http://i')
              + '.po.st/static/v4/post-widget.js#publisherKey=test';
            var x = document.getElementsByTagName('script')[0];
            x.parentNode.insertBefore(s, x);

        })();     
            var pwidget_config = {track:true};
    </script>


In your home page alone, To Disable tracking add this below code snippet:

<script language="javascript">
    var pwidget_config = {track:false};
</script>
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk