Megaphone

The Megaphone connector provides automated access to Megaphone analytics through Megaphone API and Megaphone logs imported through Amazon S3.

Prerequisites

For all reports other than Impressions and Metrics You will need to create a Megaphone Key in the Key Editor with the following property:

API Token
To generate your Megaphone API token, you will use your Megaphone CMS

For the Impressions and Metrics report you will need to create an AWS Key with the following properties:

Amazon AWS IAM Key/Secret Pair
An access key ID and secret access key created as a set and managed through the AWS Management Console. See the AWS security credentials documentation for more details.
Bucket Path
The unique, DNS-compliant name for your bucket
File Path
The path within the bucket under which Megaphone log files will be found.

Scheduling

Except for the Impressions and Metrics report, the Megaphone connector can be scheduled to ingest data once per day at a user-defined hour and timezone.

By default, the connector will run once at 6am PT.

See Daily Scheduling for more information.

For the Impressions and Metrics report, use the scheduling as prescribed in the Amazon S3 connector.

Campaign, Orders, and Advertisements

Note that for this connector the type is set to megaphone:campaign_bundle

Parameters

organization_id string
required
Check your Organization Settings in Megaphone to get this identifier.

Sample Switchboard Script

download bundle megaphone_campaigns {
    type: "megaphone:campaign_bundle";
    key: "megaphone_token_svc-megaphone";
    organization_id: "XXXXXX";

    table campaigns using {
        // See https://jsapi.apiary.io/apis/megaphoneapi/introduction/data-model/campaign.html
        "id": string;
        "createdAt": string;
        "updatedAt": string;
        "title": string;
        "advertiserId": string;
        "organizationId": string;
        "totalRevenueCents": integer;
        "totalRevenueCurrency": string;
        "durationInSeconds": integer;
    };

    table orders using {
        // See https://jsapi.apiary.io/apis/megaphoneapi/introduction/data-model/order.html
        "id": string;
        "createdAt": string;
        "updatedAt": string;
        "title": string;
        "region": string;
        "scheduledAt": string;
        "impressionsCap": integer;
        "startAt": string;
        "endAt": string;
        "adhash": string;
        "priority":integer;
        "position": integer;
        "campaignId": string;
        "organization_id": string;
        "impressionsGoal":  string;
        "revenueCents": integer;
        "revenueCurrency": string;
        "notes": string;
        "flightTimezone": string;
        "geotargets": string;
        "state": string;
        "audioStatus": string;
        "copyNeeded": boolean("true", "false", false);
        "promoCode": string;
        "vanityUrl": string;
        "promo": boolean("true", "false", false);
        "targets": [json];
    };

    table advertisements using {
        // See https://jsapi.apiary.io/apis/megaphoneapi/introduction/data-model/advertisement.html
        "id": string;
        "audioFile": string;
        "audioFileProcessing": boolean("true", "false", false);
        "audioFileDuration": float;
        "insertionPoint": string;
        "position": integer;
        "createdAt": string;
        "updatedAt": string;
        "originalFilename": string;
        "orderID": string;
        "promoID": string;
    };
};

Podcasts, Episodes, and Networks

Note that for this connector the type is set to megaphone:podcast_bundle

Parameters

organization_id string
required
Check your Organization Settings in Megaphone to get this identifier.

Sample Switchboard Script

download bundle megaphone_podcasts_raw {
    type: "megaphone:podcast_bundle";
    key: "XXXX";
    
    organization_id: "XXXXXX";

    // You must name the table podcasts, and similarly for other tables below.
   
 table podcasts using {
        // See https://jsapi.apiary.io/apis/megaphoneapi/introduction/data-model/podcast.html
        "id": string;
         "createdAt": string; 
         "updatedAt": string; 
         "title": string; 
         "link": string;
         "copyright": string;
         "author": string;
         "imageFile": string; 
         "explicit": boolean("true", "false", false);
         "ownerName": string;
         "subtitle": string;
         "summary":  string;
         "ownerEmail":  string;
         "language":  string;
         "itunesCategories": string; 
         "uid": string;
         "category": string;
         "redirectUrl": string;
         "itunesActive": boolean("true", "false", false);
         "slug":  string;
         "networkId": string;
         "redirectedAt":  string;
         "recurringImport": boolean("true", "false", false);
         "originalRssUrl": string;
         "itunesIdentifier": string;
         "stitcherIdentifier": string;
         "episodesCount": integer;
         "podtracEnabled": boolean("true", "false", false);
         "spotifyIdentifier": string;
         "googlePlayIdentifier":  string;
         "googlePodcastsIdentifier":  string;
         "iheartIdentifier":  string;
         "episodeLimit":  integer;
         "feedUrl": string;
         "externalId":  string;
         "defaultPreCount":  string;
         "defaultPostCount":  string;
         "network_id": string;
         "advertisingTags": string; 
         "podcastType": string; 
    };

    table episodes using {
        // See https://jsapi.apiary.io/apis/megaphoneapi/introduction/data-model/episode.html
        "id": string;
        "updatedAt": string;
        "createdAt": string;
        "title": string;
        "pubdate": string;
        "author": string;
        "imageFile": string;
        "explicit": boolean("true", "false", false);
        "subtitle": string;
        "summary": string;
        "audioFile": string;
        "downloadUrl": string;
        "size": integer;
        "duration": float;
        "uid": string;
        "originalUrl": string;
        "bitrate": integer;
        "samplerate": integer;
        "channelMode":  string;
        "vbr":  boolean("true", "false", false);
        "audioFileProcessing": boolean("true", "false", false);
        "podcastId": string;
        "preCount": integer;
        "postCount": integer;
        "insertionPoints": string;
        "id3File": string;
        "id3FileProcessing": boolean("true", "false", false);
        "id3FileSize": integer;
        "parentId": string;
        "guid": string;
        "soundcloudIdentifier": string;
        "pubdateTimezone": string;
        "originalFilename": string;
        "preOffset": float;
        "postOffset": float;
        "spotifyIdentifier": string;
        "expectedAdhash": string;
        "audioFileUpdatedAt": string;
        "draft": boolean("true", "false", false);
        "externalId": string;
        "published": boolean("true", "false", false);
        "podcastAuthor": string; 
        "podcastTitle": string; 
        "podcastItunesCategories": string; 
        "episodeTitle": string; 
        "seasonNumber": float; 
        "advertisingTags": string; 
        "cleanTitle": string;
        "networkId": string; 
        "episodeNumber": float; 
        "customFields": string; 
        "episodeType": string;
    };
    
    table networks using {
        // See https://jsapi.apiary.io/apis/megaphoneapi/introduction/data-model/networks.html
        createdAt: datetime;
        id: string;
        name: string;
        code: string;
        podcastCount: integer;
        report_type: string;
        organization_id: string;
    };
};

Promos

Note that for this connector the type is set to megaphone:promos

Parameters

organization_id string
required
Check your Organization Settings in Megaphone to get this identifier.

Sample Switchboard Script

download megaphone_promos_raw from {
    type: "megaphone:promos";
    key: "XXXX";
    organization_id: "XXXXXX";
} using {
    // See https://jsapi.apiary.io/apis/megaphoneapi/introduction/data-model/promo.html
    "id": string;
    "createdAt": string;
    "updatedAt": string;
    "title": string;
    "region": string;
    "scheduledAt": string;
    "impressionsCap": integer;
    "organizationId":  string;
    "startAt": string;
    "endAt": string;
    "adhash": string;
    "priority": integer;
    "position": integer;
    "impressionsGoal":  string;
    "revenueCents": integer;
    "revenueCurrency":  string;
    "notes": string;
    "flightTimezone": string;
    "geotargets": string;
    "state": string;
    "audioStatus": string;
    "copyNeeded": boolean("true", "false", false);
    "promoCode": string;
    "vanityUrl": string;
    "promo": boolean("true", "false", false);
    "targets": [json];
};

Impressions and Metrics

For this data, we recommend using our Amazon S3 with your Megaphone logs ( type = s3_ng )

Parameters

For full details on the parameters for this SBS script please see our Amazon S3

pattern string list
required
A list of requested file patterns
datetime_pattern string
required
This will be *YYYY-MM-DD* for Megaphone
format string
required
you will need one download operation where this is set to json and another where the default is used
header_row string
required
you will need one download operation where this is set to false (when the format is json) and another where the value is true (no format specified)

Sample Switchboard Script

download megaphone_daily_metrics_raw from {
    type: "s3_ng";
    pattern: "s3://megaphone-metrics-intake/metrics-day-YYYY-MM-DD.json.gz";
    key: "XXXXX";
    datetime_pattern: "*YYYY-MM-DD*";
    header_row: true;
    lookback_days: 120;
    period_hours: 1;
} using {
    filename: string;
    created_at: datetime;
    ip: string;
    episode_id: string;
    user_agent: string;
    normalized_user_agent: string;
    country: string;
    region: string;
    city: string;
    source: integer;
    bytes_sent: integer;
    filesize: integer;
    id: string;
    podcast_id: string;
    seconds_downloaded: integer;
    duration: float;
    blacklisted_ip: boolean;
    blacklisted_ua: boolean;
};
download megaphone_daily_impressions_raw from {
    type: "s3_ng";
    pattern: "s3://megaphone-metrics-intake/impression-day-YYYY-MM-DD.json.gz";
    key: "XXXXXXXX";
    datetime_pattern: "*YYYY-MM-DD*";
    header_row: false;
    format: "json";
    lookback_days: 120;
    period_hours: 1;
} using {
    filename: string;
	"metric_id": string;
	"normalized_user_agent": string;
	"created_at": datetime;
	"byte_offset": integer;
	"podcast_id": string;
	"type": string;
	"bytes_sent": integer;
	"seconds_downloaded": integer;
	"network_id": string;
	"episode_id": string;
	"organization_id": string;
	"position": integer;
	"order_id": string;
};