Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jtsternberg/af35121f209c4a65c4699bfbedf29149 to your computer and use it in GitHub Desktop.

Select an option

Save jtsternberg/af35121f209c4a65c4699bfbedf29149 to your computer and use it in GitHub Desktop.

Revisions

  1. jtsternberg revised this gist Apr 17, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions optin-monster-alternate-adobe-analytics.js
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,8 @@ jQuery( function( $ ) {
    }
    };

    // Based on what we know from the docs, the event ids should be appended to the s.events string.
    // https://marketing.adobe.com/resources/help/en_US/sc/implement/events.html
    function trackEvent( eventId ) {
    if ( s.events && s.events.length ) {
    s.events += ',' + eventId;
  2. jtsternberg revised this gist Apr 17, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions optin-monster-alternate-adobe-analytics.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    jQuery( function( $ ) {
    var campaignEventMap = {
    'nklsasuw43ypqumlh7mn' : { // Campaign #1
    'OptinMonsterOnShow' : 'event6', // Event ID from created event in Adobe
    'OptinMonsterOptinSuccess' : 'event7' // Event ID from created event in Adobe
    'OptinMonsterOnShow' : 'event6', // Event ID from created event in Adobe for impressions.
    'OptinMonsterOptinSuccess' : 'event7' // Event ID from created event in Adobe for conversions.
    },
    'l4eprc5lai8yn7f3vguq' : { // Campaign #2
    'OptinMonsterOnShow' : 'event8', // Event ID from created event in Adobe
    'OptinMonsterOptinSuccess' : 'event9' // Event ID from created event in Adobe
    'OptinMonsterOnShow' : 'event8', // Event ID from created event in Adobe for impressions.
    'OptinMonsterOptinSuccess' : 'event9' // Event ID from created event in Adobe for conversions.
    }
    };

  3. jtsternberg created this gist Apr 17, 2018.
    31 changes: 31 additions & 0 deletions optin-monster-alternate-adobe-analytics.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    jQuery( function( $ ) {
    var campaignEventMap = {
    'nklsasuw43ypqumlh7mn' : { // Campaign #1
    'OptinMonsterOnShow' : 'event6', // Event ID from created event in Adobe
    'OptinMonsterOptinSuccess' : 'event7' // Event ID from created event in Adobe
    },
    'l4eprc5lai8yn7f3vguq' : { // Campaign #2
    'OptinMonsterOnShow' : 'event8', // Event ID from created event in Adobe
    'OptinMonsterOptinSuccess' : 'event9' // Event ID from created event in Adobe
    }
    };

    function trackEvent( eventId ) {
    if ( s.events && s.events.length ) {
    s.events += ',' + eventId;
    } else {
    s.events = eventId;
    }
    }

    function mapAndTrackEvent( campaignSlug, eventType ) {
    var campaignEvts = campaignEventMap[ campaignSlug ];
    if ( campaignEvts && campaignEvts[ eventType ] ) {
    trackEvent( campaignEvts[ eventType ] );
    }
    }

    $( document ).on( 'OptinMonsterOnShow OptinMonsterOptinSuccess', function( evt, props, app ) {
    mapAndTrackEvent( app.getProp('optin'), evt.type );
    });
    });