T
T
TonyStark13372017-06-02 14:27:11
JavaScript
TonyStark1337, 2017-06-02 14:27:11

How to track the result of clicking on the Facebook "Share" button?

How to track the result of clicking on the Facebook "Share" button?
Hi, I made such a code myself, but it has 1 minus, everything is in order, when a person clicks on "SHARE FACEBOOK", he opens a window to share, my code tracks if a person closed the window, then he shared, but some close the window and do not share, so how do you know if a person has shared or not.
Here is the code

<script>
function openWin(){
var win = window.open("https://www.facebook.com/sharer/sharer.php?u=http://example.ru/file.php?id=<? echo $_GET ['id'];?>&rand=<? echo rand (1,8888884411);?>", "Facebook", "width=500 height=500");

var pollTimer = window.setInterval(function() {
    if (win.closed !== false) {
    window.clearInterval(pollTimer);
        someFunctionToCallWhenPopUpCloses();
  }
}, 200);

function someFunctionToCallWhenPopUpCloses() {
    window.setTimeout(function() {
        if (win.closed) {

 $('#onload_popup').bPopup().close();	

        }
    }, 1);
}}
 function checkIsLikeClicked() {
 if(document.activeElement.parentNode.id=="continue_popup"){

 //поделился 

 } else {
   // не поделился 
 setTimeout("checkIsLikeClicked()", 500);
 }
 }
 $(window).ready(function() {
 $('#onload_popup').bPopup({ modalClose: false, escClose: false, scrollBar: false});
 checkIsLikeClicked();
 }); 
 </script>

<div id="continue_popup" style="overflow: hidden; margin-left: 0px; margin-top:0px;">
    <div class="share-button" onclick="openWin()">
              Share of <strong>facebook</strong>
              
            </div>
<iframe id="continue" src="" scrolling="no" target="_blank" frameborder="0"> </iframe></div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Kuznetsov, 2017-06-02
@vitaly44

https://developers.facebook.com/docs/plugins/share... everything seems to be clear here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question