Avo
  • About
  • Pricing
  • FAQ
  • Docs
  • Login
  • Try Avo for free
  • About
  • Pricing
  • FAQ
  • Docs
  • Login
  • Try Avo for free

Setting up Custom Destinations

Sometimes the best way to integrate Avo is through a custom destination. For example for teams that:

  • have a custom pipline
  • are sending data to analytics platforms through an API (not using their SDK)

It's also sometimes possible to use a custom destination for language - analytics pairs that are not supported by Avo yet. Please contact us if you are unsure of what is the best solution for you.

To get started using a custom destination you do the following:

  1. Create a Custom Destination in the Connections tab

  2. Pull the updated code by doing avo pull in the Avo CLI

  3. Initialize Avo with a custom destination

  4. Fill in the empty methods for sending the data to your analytics destination

Below are instructions on how to initialize Avo with a custom destination for each of the supported languages:

Web

Mobile

Backend

Game Engines

Web

JavaScript

Import the Avo library into your code:

import Avo from './Avo';

// An object representing your custom pipeline
// that you pass into initAvo():

var customAvoLogger = {
  make: function(env) {
    // TODO implement
  },
  logEvent: function(eventName, eventProperties) {
    // TODO implement
  },
  setUserProperties: function(userId, userProperties) {
    // TODO implement
  },
  identify: function(userId) {
    // TODO implement
  },
  unidentify: function() {
    // TODO implement
  }
};

Call the initAvo function:

Avo.initAvo({env: 'dev'}, customAvoLogger);

TypeScript

import Avo from './Avo';

// An object representing your custom pipeline
// that you pass into initAvo():

let customAvoLogger = {
  make: function(env) {
    // TODO implement
  },
  logEvent: (eventName, eventProperties) => {
    // TODO implement
  },
  setUserProperties: (userId, userProperties) => {
    // TODO implement
  },
  identify: (userId) => {
    // TODO implement
  },
  unidentify: () => {
    // TODO implement
  }
};

Call the initAvo function:

Avo.initAvo({env: Avo.AvoEnv.Dev}, customAvoLogger);

Mobile

iOS

Objective-C

import Avo

// An object representing your custom pipeline
// that you pass into initAvo():

@interface CustomAvoLogger : NSObject <AVOCustomDestination>

@end

@implementation CustomAvoLogger : NSObject

- (void)make:(AVOEnv)avoEnv
{
    // TODO implement
}

- (void)logEvent:(nonnull NSString*)eventName withEventProperties:(nonnull NSDictionary*)eventProperties
{
    // TODO implement
}

Call the initAvo function:

CustomAvoLogger * customAvoLogger = [[CustomAvoLogger alloc] init];
[Avo initAvoWithEnv:AVOEnvDev
  customDestination:customAvoLogger];

Swift

Import the Avo library into your code:

import Avo

// An object representing your custom pipeline
// that you pass into initAvo():

class CustomAvoLogger : AvoCustomDestination {
    func make(env: AvoEnv) {
        // TODO implement
    }
    
    func logEvent(eventName: String, eventProperties: [String : Any]) {
        // TODO implement
    }
    
    func setUserProperties(userId: String, userProperties: [String : Any]) {
        // TODO implement
    }
    
    func identify(userId: String) {
        // TODO implement
    }
    
    func unidentify() {
        // TODO implement
    }
}

Call the initAvo function:

func application(
  _ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    Avo.initAvo(env: .dev, customDestination: CustomAvoLogger())
}

Where customDestination is the name of the destination in Avo.

Android

Java

Import the Avo library into your code:

import Avo

Call the initAvo() function:

Avo.initAvo(application, context, Avo.AvoEnv.DEV, new Avo.ICustomDestination() {
    public void make(Avo.AvoEnv env) {
        // TODO implement
    }

    public void logEvent(String eventName, Map<String, Object> eventProperties) {
        // TODO implement
    }

    public void setUserProperties(String userId, Map<String, Object> userProperties) {
        // TODO implement
    }

    public void identify(String userId) {
        // TODO implement
    }

    public void unidentify() {
        // TODO implement
    }
});

Kotlin

import Avo

Call the initAvo function:

Avo.initAvo(application=application, context=this, env=AvoEnv.DEV, customDestination=object : ICustomDestination {
    override fun make(env: AvoEnv) {
        // TODO implement
    }

    override fun logEvent(eventName: String, eventProperties: Map<String, *>) {
        // TODO implement
    }

    override fun setUserProperties(userId: String, userProperties: Map<String, *) {
        // TODO implement
    }

    override fun identify(userId: String) {
        // TODO implement
    }

    override fun unidentify() {
        // TODO implement
    }
})

Backend

Node JS

JavaScript

Import the Avo library into your code:

var Avo = require('./Avo.js');

// An object representing your custom pipeline
// that you pass into initAvo():

var customAvoLogger = {
  logEvent: function(userId, eventName, eventProperties) {
    // TODO implement
  },
  setUserProperties: function(userId, userProperties) {
    // TODO implement
  }
};

Call the initAvo() function:

Avo.initAvo({env: 'dev'}, customAvoLogger);

By passing in the customAvoLogger object, its logEvent() function can be used to deliver an event to any custom destination or pipeline.

TypeScript

import Avo from './Avo';

// An object representing your custom pipeline
// that you pass into initAvo():

let customAvoLogger = {
  logEvent: function(userId, eventName, eventProperties) {
    // TODO implement
  },
  setUserProperties: function(userId, userProperties) {
    // TODO implement
  }
};

Call the initAvo function:

Avo.initAvo({env: Avo.AvoEnv.Dev}, customAvoLogger);

Java

Import the Avo library into your code:

import Avo

Call the initAvo() function:

Avo.initAvo(Avo.AvoEnv.DEV, new Avo.ICustomDestination() {
  public void make(Avo.AvoEnv env) {
      // TODO implement
  }

  public void logEvent(String anonymousId, String userId, String eventName, Map<String, Object> eventProperties) {
      // TODO implement
  }

  public void setUserProperties(String userId, Map<String, Object> userProperties) {
      // TODO implement
  }
});

PHP

require_once './Avo';

// An object representing your custom pipeline
// that you pass into initAvo():
class CustomAvoLogger {
    public function make($env) {
        // TODO implement
    }

    public function logEvent($userId, $eventName, $eventProperties) {
        // TODO implement
    }

    public function setUserProperties($userId, $userProperties) {
        // TODO implement
    }
}

Call the initAvo function:

Avo::initAvo([
  'env' => 'dev',
  'customDestinationInstance' => new CustomAvoLogger,
]);

Python

Import the Avo library into your code:

from __future__ import print_function

import avo

# An object representing your custom pipeline
# that you pass into init_avo():
class CustomAvoLogger(object):
    def __init__(self):
        self.env = None

    def make(self, env):
        pass

    def track_event(self, user_id, event_name, event_properties):
        pass

    def set_user_properties(self, user_id, user_properties):
        pass

Call the init_avo() function:

avo.init_avo(options={'env': 'dev'}, custom_destination=CustomAvoLogger())

where custom_destination is the name of the custom destination in Avo.

Ruby

import Avo

// An object representing your custom pipeline
// that you pass into initAvo():
class CustomAvoLogger
  def make(env:)
    # TODO implement
  end

  def track_event(anonymous_id:, user_id:, event_name:, event_properties:)
    # TODO implement
  end

  def set_user_properties(anonymous_id:, user_id:, user_properties:)
    # TODO implement
  end
end

Call the initAvo function:

Avo.init_avo(options: {:env => :dev}, custom_destination: CustomAvoLogger.new)

Game Engines

Unity (C#)

using Avo;

Implement the custom destination:

class CustomAvoLogger : Avo.IDestination {
    public void Make(Avo.AvoEnv env) {
        // TODO implement
    }

    public void LogEvent(string eventName, IDictionary<string, object> eventProperties) {
        // TODO implement
    }

    public void SetUserProperties(string userId, IDictionary<string, object> userProperties) {
        // TODO implement
    }
}

Call the initAvo function:

Avo.initAvo(env=Avo.AvoEnv.Dev, customDestination=new CustomAvoLogger());