Giter Site home page Giter Site logo

ads-manager's Introduction

Ads Manager

Create Ads (Google Ads / Facebook Ads / Twitter Ads) with ease, period.

NOTE: This library is very much opinionated, use it at your own risk. Making it an agnostic library is the ongoing plan, your help is very much needed to make this happen!

NOTE: All the price amounts are in minor unit, 1000 = $10.00

Usage

const facebookAdsChannel = new FacebookAdsChannel('facebook-ads', {
  accessToken: 'xxxx',
  adAccountId: 'yyyy',
});
facebookAdsChannel.setDefaultValues({
  adSet: {
    billingEvent: 'IMPRESSIONS',
  },
  campaign: {
    objective: 'LINK_CLICKS',
    specialAdCategory: 'NONE',
  },
  customAudience: {
    customerFileSource: 'PARTNER_PROVIDED_ONLY',
  },
});
const googleAdsChannel = new GoogleAdsChannel('google-ads', {
  clientId: 'xxxx',
  clientSecret: 'yyyy',
  customerAccountId: 'zzzz',
  developerToken: 'aaaa',
  refreshToken: 'bbbb',
});
googleAdsChannel.setDefaultValues({
  adGroupCriteria: {
    keywords: ['alien'],
  },
  campaignCriteria: {
    languageCodes: ['en_US'],
    locationCountryCodes: ['MY'],
  },
});
const twitterAdsChannel = new TwitterAdsChannel('twitter-ads', {
  accessTokenKey: 'xxxx',
  accessTokenSecret: 'yyyy',
  adAccountId: 'zzzz',
  consumerKey: 'aaaa',
  consumerSecret: 'bbbb',
});

const adsManager = new AdsManager({
  channels: [facebookAdsChannel, googleAdsChannel, twitterAdsChannel],
  logging: true,
});

adsManager.use<FacebookAdsChannel>('facebook-ads')?.createCampaign({
  adCreatives: [
    {
      headline: 'I am headline',
      description: 'I am desc',
      imageUrl: 'https://the-lib-will-automatically-download-and-convert-for-you.com',
      link: 'https://wherearethealiens.com',
      pageId: 'zzzz',
      text: 'I am text',
    },
  ],
  adSet: {
    bidAmount: 1000, // All the price amounts are in `minor` unit, 1000 = $10.00
    optimizationGoal: 'IMPRESSIONS',
    startTime: '2020-02-20',
    endTime: '2020-02-25',
  },
  campaign: {
    dailyBudget: 1000,
    lifetimeBudget: 10000,
  },
  customAudience: {
    description: 'I am custom audience desc',
  },
  name: 'My First Facebook Ads',
  status: 'ACTIVE',
});

adsManager.use<GoogleAdsChannel>('google-ads')?.createCampaign({
  adGroupAd: {
    businessName: 'dddd',
    callToActionText: 'Learn More',
    descriptions: ['I am desc 1', 'I am desc 2'],
    headlines: ['I am headline 1', 'I am headline 2', 'I am headline 3'],
    imageUrls: ['https://the-lib-will-automatically-download-and-convert-for-you.com'],
    squareImageUrls: ['https://the-lib-will-automatically-download-and-convert-for-you-square.com'],
    url: 'https://wherearethealiens.com',
    displayUrlPaths: ['displaypath1', 'displaypath2'],
  },
  adGroupCriteria: {
    keywords: ['alien'],
  },
  campaign: {
    advertisingChannelType: 'DISPLAY',
    biddingStrategyConfig: { cpcBidCeilingAmount: 1000 },
    biddingStrategyType: 'TARGET_SPEND',
    endDate: '2020-01-05',
    startDate: '2020-01-01',
  },
  campaignBudget: {
    dailyAmount: 5000,
    totalAmount: 10000,
  },
  campaignCriteria: {
    languageCodes: ['en_US'],
    locationCountryCodes: ['MY'],
  },
  name: 'My First Google Ads',
  status: 'ENABLED',
});

adsManager.use<TwitterAdsChannel>('twitter-ads')?.createCampaign({
  campaign: {
    dailyBudget: 1000,
    fundingInstrumentId: 'cccc',
    endTime: '2020-01-05',
    startTime: '2020-01-01',
    totalBudget: 10000,
  },
  lineItem: {
    bidAmount: 1000,
  },
  name: 'My First Twitter Ads',
  status: 'ACTIVE',
  tailoredAudienceId: 'eeee',
  tweet: {
    asUserId: 'ffff',
    mediaUrls: ['https://the-lib-will-automatically-download-and-convert-for-you.com'],
    text: 'I am text',
    url: 'https://wherearethealiens.com',
  },
});

Build your own channel

WIP

TODO

  • Facebook Ads channel
  • Google Ads channel
  • Twitter Ads channel
  • Better documentation
  • Better typing
  • Add logs
  • Add tests
  • Add validations
  • Check possible parameters for the chosen type, (eg. Google Ads: Search Type and Display Type have different set of bidding strategies)
  • Revert strategy? If campaign failed to create, cascade delete!

ads-manager's People

Contributors

leesiongchan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

stackcraftsman

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.