Developer Console

comScore Analytics Component

 IV: Add Components for More Functionality

comScore provides in-depth analytics for your app, including insight into all playback events with your media and details about advertising message playback. Fire App Builder integrates the necessary comScore code to send the measurement data to comScore's servers. All you need to do in Fire App Builder is enable the component and configure your comScore keys. To ensure the security of your comScore keys, Fire App Builder also provides a utility to encrypt your keys.

Step 1: Configure the comScore Analytics Component

  1. Expand Gradle Scripts and open settings.gradle (Project Settings).
  2. Uncomment the lines under the two instances of the comments that say // Uncomment when using ComScore Analytics. When you uncomment the first instance, it looks like this:

    // Uncomment when using ComScore Analytics
    ':comscore',
    

    When you uncomment the second instance, it looks like this:

    // Uncomment when using ComScore Analytics
    project(':comscore').projectDir = new File(rootProject.projectDir, '../ComScoreAnalyticsComponent/libs/comscore')
    
  3. Load the comScore Analytics Component into your app. See Add or Remove a Component for details.

    Be sure to remove any other analytics components that are loaded in your app (such as Crashlytics, OmnitureAnalyticsComponent, GoogleAnalyticsComponent, or LoggerAnalyticsComponent).

  4. Click Save and then click Resync Project with Gradle Files button .

    If you're prompted to install any missing platforms or files, follow the prompts to do so.

  5. Go to ComScoreAnalyticsComponent > res > values > custom.xml and copy the tags inside the resources element. For example:

    <!-- Encrypted ComScore client token for your application, encrypt it using ResourceObfuscationStandaloneUtility -->
    <string name="encrypted_comscore_client_id">encrypted_comscore_client_id</string>
    
    <!-- Encrypted ComScore app id for your application, encrypt it using ResourceObfuscationStandaloneUtility -->
    <string name="encrypted_comscore_publisher_secret">encrypted_comscore_publisher_secret</string>
    
    <!-- PseudoRandom strings, used to generate random key for encrypting/decrypting ComScore resources.
    These keys should always remain in sync with the keys used by ResourceObfuscationStandaloneUtility -->
    <string name="comscore_key_1">comscore_key_1</string>
    <string name="comscore_key_2">comscore_key_2</string>
    <string name="comscore_key_3">comscore_key_3</string>
    <string name="comscore_key_4">comscore_key_4</string>
    <string name="comscore_key_5">comscore_key_5</string>
    <string name="comscore_key_6">comscore_key_6</string>
    
  6. Paste the copied content into your app's custom.xml file (located in resources > values).
  7. Follow the steps in the next section, Encrypt your comSore Keys, to encrypt the comScore Client ID and Publisher Secret values. After you encrypt these values, you will insert them into the encrypted_comscore_client_id and encrypted_comscore_publisher_secret elements. To make the encryption, you will also type random strings into the comscore_key_[#] values.

Step 2. Encrypt your comScore Keys

In this section, you will encrypt the values for your for comScore Client ID and Publisher Secret keys. You will then insert the encrypted keys into the encrypted_comscore_client_id and encrypted_comscore_publisher_secret elements in your app's custom.xml file.

  1. Get your client ID and Publisher Secret from comScore.
  2. Open your app's custom.xml file (inside res > values).
  3. Type a random alphanumeric string for each of the comscore_key_[#] values. For example:

    <string name="comscore_key_1">calypso</string>
    <string name="comscore_key_2">something_random</string>
    <string name="comscore_key_3">more_random_stuff</string>
    <string name="comscore_key_4">dadadadada</string>
    <string name="comscore_key_5">qwertfghyufksld</string>
    <string name="comscore_key_6">myfinalkey</string>
    

    These pseudo random strings are used to generate random keys for encrypting/decrypting the ComScore resources with the ResourceObfuscationStandaloneUtility in Fire App Builder.

  4. In the Android View, expand the Utils > java > com > amazon > utils > security folder and open the ResourceObfuscationStandaloneUtility class.
  5. In the getRandomStringsForKey() method, enter the values you used for comscore_key_1, comscore_key_2, and comscore_key_3 respectively.

    For example, assuming these first 3 keys are the ones displayed in the previous code sample, you would enter the following:

    private static String[] getRandomStringsForKey() {
    
        return new String[]{
                "calypso",
                "something_random",
                "more_random_stuff"
        };
    }
    

    In this example, the values are as follows:

    • calypso is the value used for comscore_key_1.
    • something_random is the value used for comscore_key_2.
    • more_random_stuff is the value used for comscore_key_3.
  6. In the getRandomStringsForIv() method, enter the values you used for comscore_key_4, random_key_5, random_key_6 respectively. For example:

        private static String[] getRandomStringsForIv() {
    
            return new String[]{
                    "dadadadada",
                    "qwertfghyufksld",
                    "myfinalkey"
            };
        }
    }
    

    In this example, the values are as follows:

    • dadadadada is the value used for comscore_key_4.
    • qwertfghyufksld is the value used for comscore_key_5.
    • myfinalkey is the value used for comscore_key_6.
  7. In the getPlainTextToEncrypt() method, insert your comScore Client ID key in place of Encrypt_this_text:

     private static String getPlainTextToEncrypt() {
            return "123456789";
        }
    
  8. Right-click the ResourceObfuscationStandaloneUtility.java file and select Run 'ResourceObfusc…main().
  9. Look for the encrypted result printed to the console. It will look something like this:

    Encrypted version of plain text 123456789 is MVfm5qWBdsfkl3i876MaAr0/pB7Pan9ijvQ8MtP3k=
    
  10. Copy your encrypted comScore Client ID key and paste it into the encrypted_comscore_client_id string's value in your app's custom.xml file. For example:

    <string name="encrypted_comscore_client_id">Hgei944983ljdfHoaQ==</string>
    
  11. Repeat steps 7 through 10 again, but this time insert your comScore Publisher Secret key into getPlainTextToEncrypt() instead of your comScore Client ID. After you generate the encrypted value, copy and paste it into the encrypted_comscore_publisher_secret string's value in your app's custom.xml file.

Verify that comScore Is Sending Data

To verify that comScore is sending data:

  1. Run your app.
  2. Click Android Monitor at the bottom of Android Studio to open the event log.
  3. In the blank field the left of the Regex check box, filter on the word comscore.
  4. Watch a video in your app.

    You will see event data sent such as the following:

    75/com.amazon.android.calypso D/ComScoreAnalytics: Tracking Action: ACTION_AD_START
    06-27 19:09:14.727 31975-31975/com.amazon.android.calypso D/ComScoreAnalytics: Action has the following attributes: {ATTRIBUTE_ADVERTISEMENT_TYPE=postroll, ATTRIBUTE_VIDEO_TYPE=video, ATTRIBUTE_VIDEO_ID=169313, ATTRIBUTE_AD_ID=709684216, ATTRIBUTE_VIDEO_CURRENT_POSITION=86507, ATTRIBUTE_AD_DURATION=10000, ATTRIBUTE_TITLE=Beautiful Whale Tail Uvita Costa Rica}
    06-27 19:09:25.016 31975-31975/com.amazon.android.calypso D/ComScoreAnalytics: Tracking Action: ACTION_AD_COMPLETE
    

    When you log into your comScore Analytics dashboard, these events are graphed.


Last updated: May 23, 2017