Media Analytics Module for AMP iOS

Document created by Herberth Alvarado Champion on May 15, 2017Last modified by Herberth Alvarado Champion on May 15, 2017
Version 3Show Document
  • View in full screen mode

Maintainers: David Cortes Saenz & Miguel Lopez Valenciano

 

 

Avoiding manual implementation of media-related beacons is this module’s goal, our implementation uses our own AMP callbacks to notify Media Analytics so you don’t have to.

 

Installation

Just import the AmpMediaAnalytics.framework in your project. For more information check out the AmpCore’s documentation.

*Note: Make sure to add the frameworks as Embedded Binaries or you’ll get an error about a missing image. *

 

How to Use

Let’s first import the required frameworks:

import AmpCore
import AmpMediaAnalytics

 

Then, let’s add the related variables in our UIViewController:

var ampPlayer: AmpPlayer!
var ampMediaAnalytics: AmpMediaAnalyticsManager!


And it’s time to instantiate them now, in your viewDidLoad function:

// Instantiate player

self.ampPlayer = AmpPlayer(parentView: self.view)
self.ampPlayer.autoplay = true
self.ampPlayer.setLicense(license)

 

// Register yourself as an observer if required
self.ampPlayer.registerObserver(self)

 

// Define your desired dimensions, these are some test ones:
let customDimensions = [
   "title": "AKaMTitle",
   "category": "AKamCategory",
   "playerId": "AKAM AVPlayer playerId",
   "device": "AKAM AVPlayer device",
   "show": "AKAM AVPlayer$show"
]

 

// Instantiate the Media Analytics Manager
self.ampMA = AmpMediaAnalyticsManager(ampPlayer: self.ampPlayer, configUrl: analyticsUrl, customDimensions: customDimensions)

 

// Afterwards, let's ask our `ampPlayer` to handle our stream
self.ampPlayer.handleUrl(url)

 

And that’s basically it, with just those few steps, you have a working integration between AMP and Media Analytics.

Attachments

    Outcomes