ma-agent
v0.0.12
Published
The MA agent collects data to evaluate the effectiveness of advertising.
Downloads
296
Readme
MA Agent
The MA agent collects data to evaluate the effectiveness of advertising.
MA Agent Installation
npm i ma-agent
MA Agent initialization
es modules
import { MaAgent } from '@kosmos/ma-agent';
window.mAgent = new MaAgent({
defaultData: {client_version: '<client version>'},
url: '<url>',
token: '<token>'
});
From bundle
<script src="./dist/bundle.umd.js"></script>
<script type="text/javascript">
const {MaAgent} = maAgent;
window.mAgent = new maAgent.MaAgent({
defaultData: {client_version: '<client version>'},
url: '<url>',
token: '<token>'
});
</script>
Sending post backs about events using the ma agent
Send visit event
After the download of your game is complete.
!!important!! This function should be called after FBInstant.initializeAsync()
import { EventTypes } from '@kosmos/ma-agent';
window.mAgent
.sendEvent({
user_id: '<user_id|social_id>', // the user ID on the server or the id that was issued by the platform
data: {
social_id: '<social_id>', //the ID provided by the platform
is_install: 1 // if this is a new user in the game
},
event_type: EventTypes.visit //2
});
Send Transaction event
After Transaction is complete
import { EventTypes } from '@kosmos/ma-agent';
window.mAgent
.sendEvent({
user_id: '<user_id|social_id: string>', // the user ID on the server or the id that was issued by the platform <string>
data: {
social_id: '<social_id: string>', // the ID provided by the platform
transaction_id: 'transaction123', // transaction ID provided by the platform
price: 10000.0, // purchaise price
proceed: 1000, // total income from the purchase without platform fees and local tax
currency: 'USD' // currency code
},
event_type: EventTypes.transaction // 1
});
Send Raw Transaction event without proceed field
Client Transaction
import { EventTypes } from '@kosmos/ma-agent';
window.mAgent
.sendEvent({
user_id: '<user_id|social_id: string>', // the user ID on the server or the id that was issued by the platform <string>
data: {
social_id: '<social_id: string>', // the ID provided by the platform
transaction_id: 'transaction123', // transaction ID provided by the platform
price: 10000.0, // <optional> purchaise price
currency: 'USD', // <optional> currency code
purchase_platform: 'GOOGLE' // purchase_platform in fb receipt (string)
},
event_type: EventTypes.raw_transaction // 5
});
Send AdShow event
After the ad is shown
import { EventTypes } from '@kosmos/ma-agent';
window.mAgent
.sendEvent({
user_id: '<user_id|social_id: string>', // the user ID on the server or the id that was issued by the platform
data: {
ad_type: 'Interstitial|rewarded|...',
revenue: 0.5, // total income from the ad shown without platform fees and local tax
currency: 'USD', // currency code
count: 1, // Number of ad impressions
client_platform: 1,
},
event_type: EventTypes.ad_shown // 3
});