Example: Analytics data via REST API

Example: Analytics data via REST API

Our REST API is a powerful tool which allows you to gather data and process it depending on your needs. We have both the documentation and an API call tester embedded here.

This example will show you how to get the actions and reached users per campaign on the app specified by the resourceKey. This is using the analytics module of the MOCA V2 REST API.

What do you need?

  • The resourceKey (it's the resource identifier. Can be App, place, etc).
  • A valid Access Token (The API uses OAuth 2.0).
  • The domain to be used (in this demo we use the campaign domain. Use https://api.mocaplatform.com/v2/analytics/domains/ to get the list domains).
  • The metrics to be received (columns).
  • The dimensions to be received (rows).
  • The interval that contains the data.

Steps:

  1. Go to https://developer.mocaplatform.com/docs/moca-api-analytics-query, scroll down and use our Try It Out module.
  2. Add the token to the tester. You must click on the key symbol and add the Access Token. If you do not have one, please contact support and request it.
  3. Next step is adding the resource key. In this case we will use the App Key you will find in the MOCA console settings under API Keys.
  4. Now add the domain. Let's use the campaign domain.
  5. The metrics per domain are seen when using the following call: https://api.mocaplatform.com/v2/analytics/domains/<domain>. For this example we use reached_users and actions.
  6. The dimensions also appear in the same response. We'll use campaign and app:version.
  7. The interval to be used in this case is last7days.
  8. Now Try it!

The MOCA REST API will give you a JSON with the data you requested. You'll get the reached users, amount of times opened and both the App version and Campaign name for that App. With minor tweaks (replace reached_users for actions_opened and delete App:version) and minimal data processing (actions_opened divided by actions) you can get a Click Through Rate for your campaigns and experiences.



 


    • Related Articles

    • How do I use the MOCA REST API?

      MOCA's REST API is a powerful tool to gather the data we have for your account, and process it at your end in order to get deeper insights into your data. The documentation for the REST API can be found here. It's extensive and covers all accessible ...
    • How do I receive MOCA SDK actions in my third party API?

      MOCA has a feature called Cloud-Hook. This feature enables the MOCA SDK embedded into the client mobile App to deliver location-triggered actions directly to the Third Party campaigns module and deliver segmented and personalized content to end ...
    • Do you have a Web SDK?

      Yes, MOCA has the JS SDK that enables web applications written in HTML5/CSS to track a variety of user signals, such as browser, operating system, events triggered by user navigation and much more. MOCA JavaScript SDK is designed with this in mind: ...
    • How to set MOCA SDK to download only when connected to Wi-Fi

      The MOCA SDK has the capability to download data only when the "Wi-Fi Only" data transmission is activated. In order to do so, here are the calls for both Android and iOS: Android SDK MOCA API Java /** * Returns true if the "Wifi Only" data ...
    • Strategies to improve battery usage of our SDKs

      At MOCA we have designed our SDKs to be very efficient and use the minimum necessary battery for Proximity Marketing use cases. We prefer low energy solutions that do not involve GPS and, for Android, offer ways to fine tune the sensitivity of the ...