Getting started

Here is how you can start using our solution in 5 minutes.

The easiest integration you've ever done

Activate "Debug mode" to test your solution, or wait for website validation

Copy & Paste your Moonkey code anywhere in your content (example below)


<script type="text/javascript">

window.MoonkeyAsyncInit = function () {

(new MoonkeyContent).init({
clientId: "1048007453",
contentIdentifier: "3119374830",
inApps: false,
version: "1.0",
lang: "en_US",
onSuccess: function(contentIdentifier, transactionId, accessToken) {
//Your onSuccess callback
},
});
};

(function (d,s,id) {
var js, mkjs = d.getElementsByTagName(s)[0];
if(d.getElementById(id)) {return;}
js = d.createElement(s);
js.id = id;
js.src = "//app.moonkey.net/js/JSMoonkit.min.js";
mkjs.parentNode.insertBefore(js,mkjs);
})(document,"script","moonkey-script");
</script> <div class="moonkey-code"
data-moonkey-contentIdentifier="3119374830"
type-moonkey="paywall">
</div>

Step by step integration

  • Sign up as a publisher

    http://manager.moonkey.net/signup.html

    Sign up Moonkey
  • Register a new website

    Fill in your website URL at My Websites

    New Website Moonkey
  • Set a new content for your website

    A content is defined by a set of parameters (placement, price, etc.). You can define as many contents as you want to fit your needs, e.g. one by category, one by section, one by option, etc.

    Fill in your content parameters at Contents

    New Website Moonkey
  • Add the code in your website

    Click on the "" icon corresponding to your content

    Contents Code Moonkey

    Copy & Paste your Moonkey code anywhere in your content (example below)

    
    <script type="text/javascript">

    window.MoonkeyAsyncInit = function () {

    (new MoonkeyContent).init({
    clientId: "1048007453",
    contentIdentifier: "3119374830",
    inApps: false,
    version: "1.0",
    lang: "en_US",
    onMoonkeyShow: function(contentIdentifier) {
    //Your onMoonkeyShow callback
    },
    onMoonkeyHide: function(contentIdentifier) {
    //Your onMoonkeyHide callback
    },
    onSuccess: function(contentIdentifier, transactionId, accessToken) {
    //Your onSuccess callback
    },
    onClose: function (contentIdentifier) {
    //Your onClose callback
    }
    });
    };

    (function (d,s,id) {
    var js, mkjs = d.getElementsByTagName(s)[0];
    if(d.getElementById(id)) {return;}
    js = d.createElement(s);
    js.id = id;
    js.src = "//app.moonkey.net/js/JSMoonkit.min.js";
    mkjs.parentNode.insertBefore(js,mkjs);
    })(document,"script","moonkey-script");
    </script> <div class="moonkey-code"
    data-moonkey-contentIdentifier="3119374830"
    type-moonkey="paywall">
    </div>
  • Choose your placement type

    Click here to see placement details:

    Default Button Image

    Default button

    Custom Button Image

    Custom button

    Paywall Image

    Paywall

  • Test the Moonkey solution

    Activate the "Debug mode" in the Apps/Websites page

    Debug Mode Moonkey

    Using this mode, you will be able to unlock your content without any advertising. It allows you to test your solution and the associated settings.
    Do not use "Debug Mode" in production environment.

Placement types

Choose the Moonkey solution you want on your website.

The button that will be automatically displayed if there is no other button attribute defined.


Unlock

    <div class="moonkey-code"
data-moonkey-contentIdentifier="3119374830"
></div>
Customize your Moonkey button by setting your image URL.


Unlock

<div class="moonkey-code"
data-moonkey-contentIdentifier="3119374830"
img-moonkey-src="http://www.mywebsite.com/.../mycustombutton.png"
></div>
Choose our paywall to get a complete solution.


Unlock

<div class="moonkey-code"
data-moonkey-contentIdentifier="3119374830"
type-moonkey="paywall"
></div>
Customize your paywall by changing the introduction message and the button.


Unlock

<div class="moonkey-code"
data-moonkey-contentIdentifier="3119374830"
type-moonkey="paywall"
intro-moonkey="My custom introduction"
img-moonkey-src="http://www.mywebsite.com/.../mycustombutton.png"
></div>

Success callback

Function : onSuccess
Fired when a user has unlocked your content.


onSuccess : function(contentIdentifier, transactionId, accessToken) {
    //Your onSuccess callback
}

Server-to-server validation (optional)

  • Get the transactionId and the accessToken from the onSuccess Callback
  • Send a request to your server with the transactionId and the accessToken
  • Send an HTTP POST request from your server to the Moonkey servers with the transactionId and the accessToken
  • POST parameters to send : transactionId | accessToken
  • Parse the JSON response to check the validity of the transaction
  • - status | Value : 0 (Valid accessToken) - 1 (Invalid accessToken) - 2 (Debug accessToken)
    - message | Value : a message describing the request
    - data (status = 0 only)
    * application | Value : name of the app/website
    * price | Value : price of the content
    * floor_price | Value : floor price of the content
    * date | Value : date of the transaction

    Example of valid accessToken response :
    
    {
    	status: 0,
    	message: "Access Token is valid.",
    	data: {
    		application: "Fleex",
    		price: "0.10",
    		floor_price: "0.02",
    		date: "2017-01-01"
    	}
    }
    

    Example of invalid accessToken response :
    
    {
    	status: 1,
    	message: "Invalid Access Token."
    }
    

    If the API request is wrong, you will get something like :
    
    {
    	error: {
    		message: "You must send a transactionId and an accessToken.",
    		request: {
    			method: "verifyAccessToken"
    		}
    	}
    }
    
  • Give your user access to the premium content (redirection, account, etc.)

Events (optional)

Moonkey Show

Function : onMoonkeyShow
Fired when Moonkey button access is granted


onMoonkeyShow: function(contentIdentifier) {
    //Your onMoonkeyShow callback
}

Moonkey Hide

Function : onMoonkeyHide
Fired when Moonkey button access is denied


onMoonkeyHide: function(contentIdentifier) {
    //Your onMoonkeyHide callback
}

Close

Function : onClose
Fired when a user comes back from Moonkey platform without unlocking your content


onClose : function (contentIdentifier) {
    //Your onClose callback
}

Advanced Configuration

All configuration parameters have to be included in the Object as follows :

/* ... */
/* John Doe's profile */
var userGender = "male";
var userBirthday = "1976-04-13";
var userChildDirectedTreatment = false;
var userLocation = {
    "latitude": 37.422,
    "longitude": -122.084,
    "accuracy": 10
};

/* ... */
(new MoonkeyContent).init({
    clientId: "1048007453",
    contentIdentifier: "3119374830",
    inApps: false,
    version: "1.0",
    lang: "en_US",
    gender: userGender,
    birthday: userBirthday,
    childDirectedTreatment: userChildDirectedTreatment,
    geolocation: userLocation,
    onSuccess: callSuccess
});

/*...*/


User gender

Key : gender

Type : Enum
Default : unknown
Values : male | female | unknown

    gender: "female"

/* ... */
/* John Doe's profile */
var userGender = "male";

/* ... */
(new MoonkeyContent).init({
    clientId: "1048007453",
    contentIdentifier: "3119374830",
    inApps: false,
    version: "1.0",
    lang: "en_US",
    gender: userGender,
    onSuccess: callSuccess
});

/* ... */

User birthday

Key : birthday

Type : String (date formatted like YYYY-MM-DD)

    birthday: "1976-04-13"

/* ... */
/* John Doe's profile */
var userBirthday = "1976-04-13";

/* ... */
(new MoonkeyContent).init({
    clientId: "1048007453",
    contentIdentifier: "3119374830",
    inApps: false,
    version: "1.0",
    lang: "en_US",
    birthday: userBirthday,
    onSuccess: callSuccess
});

/* ... */

Child treatment

Key : childTreatmentDirected
Set to indicate you want Moonkey to treat your content as child-directed

Type : Boolean
Default : false

    childDirectedTreatment: false


/* ... */
/* John Doe's profile */
var userChildDirectedTreatment = false;

/* ... */
(new MoonkeyContent).init({
    clientId: "1048007453",
    contentIdentifier: "3119374830",
    inApps: false,
    version: "1.0",
    lang: "en_US",
    childDirectedTreatment: userChildDirectedTreatment,
    onSuccess: callSuccess
});

/* ... */

User location

Key : geolocation
Set to enable geolocated ads

Type : JSON
Parameters : latitude | longitude | accuracy

geolocation: {
    "latitude": 37.422,
    "longitude": -122.084,
    "accuracy": 10
}

/* ... */
/* John Doe's profile */
var userLocation = {
    "latitude": 37.422,
    "longitude": -122.084,
    "accuracy": 10
};

/* ... */
(new MoonkeyContent).init({
    clientId: "1048007453",
    contentIdentifier: "3119374830",
    inApps: false,
    version: "1.0",
    lang: "en_US",
    geolocation: userLocation,
    onSuccess: callSuccess
});

/*...*/