isocket-targeting =================

npm install isocket-targeting
1 downloads in the last day
12 downloads in the last week
58 downloads in the last month


Global Targeting Types for Node.js

Build Status NPM version

Provides easy access to common ad targeting types based on the isocket API powered by Sequelize. You can use the bundled data or your own data source.


npm install isocket-targeting --save


All configuration is done through environment variables. We suggest using dotenv to manage them.

By default, SQLite is used to store the bundled data in memory.

You can also use your own database with your own data.

  • ISOCKET_TARGETING_STORE_DIALECT - mysql, postgres, or sqlite (defaults to sqlite). See Sequelize's documentation for more info on additional installs needed for mysql and postgres
  • ISOCKET_TARGETING_STORE_DB - database name (defaults to isocket_targeting)
  • ISOCKET_TARGETING_STORE_USER - database username (defaults to '')
  • ISOCKET_TARGETING_STORE_PASS - database password (defaults to '')
  • ISOCKET_TARGETING_STORE_PATH - Only valid for SQLite. Path to storage engine (defaults to ':memory:')


Targeting = require 'isocket-targeting'

Syncing the Database

You'll need to sync your database in order to create tables that may not exist. This is always the case for SQLite in memory (default).

Targeting.sync (err) ->
  throw err if err

Loading Data

If you are using SQLite in memory, your data will be loaded automatically.

You can use SQLite in memory and provide your own data. Configure the paths to your frequency capping data and/or geo targeting data:

  • ISOCKET_TARGETING_FCAP - defaults to fcaps.csv
  • ISOCKET_TARGETING_GEO - defaults to geos.csv

The CSVs are expected to be in the following format:

u1,unique one
u2,unique two

Loading data will result in bulk creates.

Targeting.loadData (err) ->
  throw err if err



Get array of targetings by type

Targeting.getType 'geo', (err, targetings) ->
  throw new err if err

  console.log targetings
  # [{uid: 'u1', name: 'unique one'},{uid: 'u2', name: 'unique two'}]


  1. Install Grunt npm install -g grunt-cli
  2. Install test dependencies npm install
  3. Run tests grunt test
npm loves you