Programming question related to CPA

Discussion in 'CPA' started by Fixit, Jan 3, 2012.

  1. Fixit

    Fixit Newbie

    Joined:
    Nov 30, 2011
    Messages:
    48
    Likes Received:
    5
    First of all, I am sorry for my english. I speak french on a daily basis.

    I got a programming question related to CPA.. I didn't know in which of the two section I should post it. I think CPA section is the good one, if I am mistaking, you can move my thread to the programming section there is no problems..

    I am making my own content locker. I really got no problems when it come to Geo targeting or a rotation of offer from differents network.

    My question is : how do you know when a visitor complete your offer? The content locker I seen here (not the Content Locker Pro.. I mean the homemade locker) disappear after a number of second that the programmer specifie.. That's not really a locker!

    I know I could buy CLP, I have no problems with putting the money to buy it BUT I still want to know because CLP and other locker don't do what I really want to do: I want my website members to get "credits" when the complete an offer.. I need to know when they complete it to give the credit..

    Is it possible? To get a kind of "dispatch event"(don't know if it is the right expression but the actionscript programmer will understand me haha) when a user complete your offer?

    Thank you! :)
     
  2. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,868
    Likes Received:
    1,336
    A common method is to use a looping javascript function that measures the length of the browser's history (number of pages visited). So if, once the offer loads (and say we're doing a 1-page submit), the browser history length is 5 pages, you'd want the function to check the variable against 5 + 1 so that when the history length reaches 6, you know the browser has loaded a new page (indicates loading page 2 of the offer, meaning the 1st page submit is done).

    Something like:

    Code:
    var initHist = history.length;
    
    function checkHistory() {
         if (history.length == (initHist + 1)) {
              // drop locker
         }     
    }
    
    setInterval("checkHistory", 500);
    for a 1 page submit. For 2 pages, it would be initHist + 2, etc.

    However, if you have the time and know-how, you can setup a postback on your CPA if it supports it so that once the user completes the offer, the CPA pings a page on your server with some user data, which you could then store in a database. Then on your content locker page, you could have a continuous AJAX function or the like that checks the database to see if the particular user has filled out the offer.

    That second method is much more fool-proof, but it requires a lot of contingency, as in your CPA has to support postback, you need to have a way to identify the user (you can do subid and store a unique key for the user in it, because I don't think any networks postback the IP as far as I've seen), and you need to know how to code the PHP and js AJAX.
     
    • Thanks Thanks x 1
  3. Fixit

    Fixit Newbie

    Joined:
    Nov 30, 2011
    Messages:
    48
    Likes Received:
    5
    Thank a lot! I will use your first idea(the looping javascript function) for my content locker where I would probably put only one-page offer and i will try to learn more about the postback for my credits system. I think I can do it i'm kinda good at PHP/MySQL, Javascript, HTML/CSS..

    I will give you somes news if I succeed! Thank again