1. Open your client - side file and paste that code in your <HEAD> section.

< script > 
    //some default pre init 
    var XCopy = XCopy || {}; 
    XCopy.q = XCopy.q || []; 
    **//provide xcopy initialization parameters**

    XCopy.app_key = 'YOUR APPKEY '; 

    XCopy.url = 'http://app.xcopy.co'; 

    var apikey; 

    var checked = false; 

    function check() 
    { 
        var xhr = new XMLHttpRequest(); 
        apikey = document.getElementById('apikey').value; 
        xhr.open('POST', 'SERVER PATH HERE', true);    
        var params = {'apikey':apikey}; 
        xhr.onreadystatechange = function(){ 
            if (xhr.readyState != 4) return;    
            if (this.readyState == 4) { 
            if (this.status == 200) 
            {    
            checked = (this.responseText=='1'); 
            playPause(); 
            } 
            } 
        }; 
        xhr.send(JSON.stringify(params)); 
    } 

    (function() { 
        var xcp = document.createElement('script'); xcp.type = 'text/javascript'; 
        xcp.async = true; 
        //enter url of script here 
        xcp.src = 'xcopy.min.js'; 
        xcp.onload = function(){XCopy.init()}; 
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(xcp, s); 
    })(); 

    function playPause() 
    { 
        var myVideo=document.getElementById("video1"); 
        if (myVideo.paused) 
        { 
        if (!checked) 
        { 
            myVideo.style.display='none'; 
            document.getElementById("divapikey").style.display='block'; 
        } 
        else 
        { 
            if (myVideo.style.display=='none') 
            { 
                myVideo.style.display='block'; 
                document.getElementById("divapikey").style.display='none'; 
            } 
            XCopy.q.push(['begin_session']); 
            myVideo.play(); 
        } 
        } 
        else 
        { 
            myVideo.pause(); 
            XCopy.end_session(); 
        } 
    } 
< /script >

Replace 'YOUR APPKEY' with APPKEY, taken from app.xcopy.co dashboard, and 'SERVER ' with your server host

Also we assume that your video tag has "video1" ID.

2. Goto your <BODY> section and find where your video is shown:

For example you have such code:

    < video id="video1" width="600" onclick="playPause();"> 
    < source src="YOUR VIDEO FILE" type="video/mp4"> 
    </video > 

Insert the following code just above your video code:

    <div id="divapikey" style="display:none;"> 
    <input id='apikey' placeholder='Enter your apikey here'></input><br/> 
    <button type='submit' id='checkapi' onclick='check();'>check key</button>    
    <button id='getapi' onclick='window.open(\"http://signup.xcopy.co\")'>Get Api Key</button> </div>

That's all for the client part. Of course you may call all variables, finctions, tags in anyway.

3. Open your server part file, that was pointed at "SERVER PATH HERE".

Add the following code to that file :

    <?php $json = file_get_contents('php://input'); 
    $obj = json_decode($json, true); 
    $apikey = $obj['apikey']; $page=""; 
    if ((!isset($apikey))||(is_null($apikey))) 
    { $response = '0'; } 
    else { $response = file_get_contents("http://app.xcopy.co/o/check?apikey=".$apikey); } 
    echo $response; ?>

THAT'S ALL!!!