Kochava - cleveradssolutions/CAS-Track-revenue GitHub Wiki
The integration of Kochava SDK into your application is presented in the official source.
Android
More information about initialization of CAS SDK here and Kochava SDK here.
public class GlobalApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize CAS
CAS.buildManager().initialize();
// Initialize Kochava SDK
Tracker.configure(new Configuration(getApplicationContext())
.setAppGuid("_YOUR_APP_GUID_")
);
}
}
Replace _YOUR_APP_GUID_
with your App GUID. You can find this in your Kochava dashboard.
iOS
More information about initialization of CAS SDK here and Kochava SDK here.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool
{
// Initialize CAS
let manager = CAS.create(managerID: "demo",
enableTypes: [.banner, .interstitial, .rewarded],
demoAdMode: true) { complete, error in
print("[CAS Sample] Mediation manager initialization: \(complete) with error: \(String(describing: error))")
}
// Initialize Kochava SDK
KVATracker.shared.start(withAppGUIDString: "_YOUR_APP_GUID_")
}
Replace _YOUR_APP_GUID_
with your App GUID. You can find this in your Kochava dashboard.
Unity3d
More information about initialization of CAS SDK here and Kochava SDK here.
class CleverAdsSolutionsDemoScript : MonoBehaviour
{
IMediationManager manager;
void Start()
{
// Initialize CAS
manager = builder.Initialize();
}
}
We recommend placing the Kochava Configuration Prefab in your launch scene, although this can be done elsewhere if needed. Starting the tracker as early as possible will provide more accurate session reporting and help to ensure the tracker has been started before using it. Keep in mind the tracker can only be configured and started once per launch.
This string should be set to your Kochava App GUID
, which can be found in your Edit App page within the Kochava dashboard. This value is always required (unless a Partner Name is set).
An individual Kochava App should be created for each published platform and its App GUID placed in its appropriate spot in the inspector. The Unity Editor App GUID
will be used within the Editor and for any platform that a specific App GUID was not specified.
Android
Use our Ad Content Callback for tracking your Impression Level Data.
class MyActivity extends Activity implements AdCallback {
MediationManager manager;
CASBannerView banner;
FirebaseAnalytics mFirebaseAnalytics;
void createBanner() {
banner = new CASBannerView(this, manager);
banner.setListener(this);
}
void showInterstitial() {
manager.showInterstitial(MyActivity.this, this);
}
void showRewarded() {
manager.showRewarded(MyActivity.this, this);
}
@Override
void onShown(AdStatusHandler ad) {
// Executed when the ad is begin displayed.
// AdStatusHandler is information of ad impression.
Tracker.Event event = new Tracker.Event(Tracker.EVENT_TYPE_AD_VIEW)
.setAdType(adStatusHandler.getAdType().name())
.setCurrency("USD")
.setAdNetworkName(adStatusHandler.getNetwork());
if (adStatusHandler.getPriceAccuracy() != PriceAccuracy.UNDISCLOSED) {
event.setPrice(adStatusHandler.getCpm() / 1000);
event.addCustom("PriceAccuracy",
adStatusHandler.getPriceAccuracy() == PriceAccuracy.BID ? "BID" : "FLOOR");
} else {
event.addCustom("PriceAccuracy", "UNDISCLOSED");
}
Tracker.sendEvent(event);
}
}
iOS
Use our Ad Content Callback for tracking your Impression Level Data.
class AdExample : UIViewController, CASCallback {
let manager: CASMediationManager
@IBOutlet var bannerView: CASBannerView!
func createBanner() {
bannerView.rootViewController = self
bannerView.delegate = self
}
func showInterstitial() {
manager.presentInterstitial(fromRootViewController: self, callback: self)
}
func showRewarded() {
manager.presentRewardedAd(fromRootViewController: self, callback: self)
}
func willShown(ad adStatus: CASStatusHandler) {
let event = KVAEvent(type: .adView)
event.adTypeString = adStatus.adType.description
event.adNetworkNameString = adStatus.network
event.currencyString = "USD"
var params : [String : String]
if (adStatus.priceAccuracy != CASPriceAccuracy.undisclosed) {
event.priceDoubleNumber = NSNumber(value: adStatus.cpm / 1000)
if (adStatus.priceAccuracy == CASPriceAccuracy.bid) {
params["PriceAccuracy"] = "BID"
} else {
params["PriceAccuracy"] = "FLOOR"
}
} else {
params["PriceAccuracy"] = "UNDISCLOSED"
}
event.infoDictionary = params
event.send()
}
}
Unity3d
Use our Ad Content Callback for tracking your Impression Level Data.
class CleverAdsSolutionsDemoScript : MonoBehaviour
{
IMediationManager manager;
void Start()
{
manager.OnBannerAdOpening += onAdOpening;
manager.OnInterstitialAdOpening += onAdOpening;
manager.OnRewardedAdOpening += onAdOpening;
}
void showInterstitial()
{
manager.ShowAd( AdType.Interstitial );
}
void showRewarded()
{
manager.ShowAd( AdType.Rewarded );
}
void showBanner()
{
manager.ShowAd( AdType.Banner );
}
void onAdOpening(AdMetaData adMetaData)
{
// Executed when the ad is begin displayed.
// AdStatusHandler is information of ad impression.
Kochava.Event adEvent = new Kochava.Event( Kochava.EventType.AdView );
adEvent.adType = adMetaData.type.ToString();
adEvent.adNetworkName = adMetaData.network.ToString();
adEvent.currency = "USD";
if ( adMetaData.priceAccuracy != PriceAccuracy.Undisclosed )
adEvent.price = adMetaData.cpm / 1000;
adEvent.SetCustomValue( "PriceAccuracy", adMetaData.priceAccuracy.ToString() );
Kochava.Tracker.SendEvent( adEvent );
}
}