comScore Analytics Component
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
- Step 2. Encrypt your comScore Keys
- Verify that comScore Is Sending Data
Step 1: Configure the comScore Analytics Component
- Expand Gradle Scripts and open settings.gradle (Project Settings).
-
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')
-
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).
Note: You can load only one component per interface. For example, you cannot load both the Flurry Analytics component and the Omniture Analytics component, because both components use the sameIAnalytics
interface. For a list of the components by interface, see Components Overview. -
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.
-
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>
- Paste the copied content into your app's custom.xml file (located in resources > values).
- 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
andencrypted_comscore_publisher_secret
elements. To make the encryption, you will also type random strings into thecomscore_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.
- Get your client ID and Publisher Secret from comScore.
- Open your app's custom.xml file (inside res > values).
-
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.
- In the Android View, expand the Utils > java > com > amazon > utils > security folder and open the ResourceObfuscationStandaloneUtility class.
-
In the
getRandomStringsForKey()
method, enter the values you used forcomscore_key_1
,comscore_key_2
, andcomscore_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 forcomscore_key_1
.something_random
is the value used forcomscore_key_2
.more_random_stuff
is the value used forcomscore_key_3
.
-
In the
getRandomStringsForIv()
method, enter the values you used forcomscore_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 forcomscore_key_4
.qwertfghyufksld
is the value used forcomscore_key_5
.myfinalkey
is the value used forcomscore_key_6
.
-
In the
getPlainTextToEncrypt()
method, insert your comScore Client ID key in place ofEncrypt_this_text
:private static String getPlainTextToEncrypt() { return "123456789"; }
- Right-click the ResourceObfuscationStandaloneUtility.java file and select Run 'ResourceObfusc…main().
-
Look for the encrypted result printed to the console. It will look something like this:
Encrypted version of plain text 123456789 is MVfm5qWBdsfkl3i876MaAr0/pB7Pan9ijvQ8MtP3k=
-
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>
-
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.Tip: Save your random keys in a safe place, such as your company wiki, so that you always have an easy way to retrieve them. You will need these keys to decrypt the value.
Verify that comScore Is Sending Data
To verify that comScore is sending data:
- Run your app.
- Click Android Monitor at the bottom of Android Studio to open the event log.
- In the blank field the left of the Regex check box, filter on the word comscore.
-
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