Sometimes the best way to integrate Avo is through a custom destination. For example:
Please contact us if you are unsure of what is the best solution for you or if there are any analytics destinations you'd like to see supported in Avo.
To get started using a custom destination you do the following:
avo pull
in the Avo CLIWe will be referencing Avo functions, events, actions and other Avo concepts in this document. Please read the Tracking Plan doc and subdocs to get familiar with Avo concepts.
With a custom destination you'll get access to callback methods for Avo actions. The Avo generated code triggers the callbacks when corresponding Avo functions are called.
make
: Triggered during Avo initialization.
Here you will usually initialize an analytics SDK with a development or production key based on the env
parameter.logEvent
: All your analytics events are managed in the Avo dashboard. Each event gets a generated Avo function. Avo events can have a Log Event action attached. This callback is triggered when an Avo function with Log Event action is called.
Here you perform the actual event tracking, calling the track/log methods of the analytics SDK. Event name and event properties are provided as parameters.identify
: You can add the Identify User action to an event in the Avo dashboard. When calling an Avo function that includes the Identify User action you'll need to provide a user ID. Calling an Avo function that has the Identify User action will trigger this callback.
The main use cases are signup and login.
Here you would pass the user ID to the analytics SDK for it to create a new user or attach a session to an existing user.unidentify
: If you call an Avo function with the Unidentify User action, this callback will be triggered.
Here you would call an analytics SDK method to detach subsequent actions from the currently identified user.revenue
: If you add a Log Revenue
action to Avo Function this callback will be invoked.
Here you would log the revenue to your analytics destination, many of them have a special method to log revenue.page
: If you add a Log Page View
action to Avo Function this callback will be invoked.
Here you would report navigation to your analytics destination.setUserProperties
: You can add user properties to events in the Avo dashboard. When an Avo function with attached user properties is called, this callback is triggered.
Here you would attach user properties to the currently identified user in your analytics platform.Below are instructions on how to initialize Avo with a custom destination for each of the supported languages:
Import the Avo library into your code:
JavaScriptCopy12345678910111213141516171819202122232425262728import Avo from './Avo';// An object representing your custom destination// that you pass into initAvo():var customDestination = {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},revenue: function(amount, eventProperties) {// TODO implement},page: function(pageName, eventProperties) {// TODO implement}};
Call the initAvo function:
JavaScriptCopy1Avo.initAvo({ env: 'dev' }, {}, {}, customDestination);
TypeScriptCopy12345678910111213141516171819202122import Avo from './Avo';// An object representing your custom destination// that you pass into initAvo():let customDestination = {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:
TypeScriptCopy1Avo.initAvo({ env: Avo.AvoEnv.Dev }, {}, customDestination);
Objective CCopy1234567891011121314151617181920import Avo// An object representing your custom destination// that you pass into initAvo():@interface CustomDestination : NSObject <AVOCustomDestination>@end@implementation CustomDestination : NSObject- (void)make:(AVOEnv)avoEnv{// TODO implement}- (void)logEvent:(nonnull NSString*)eventName withEventProperties:(nonnull NSDictionary*)eventProperties{// TODO implement}
Call the initAvo function:
Objective CCopy123CustomDestination * customDestination = [[CustomDestination alloc] init];[Avo initAvoWithEnv:AVOEnvDevcustomDestination:customDestination];
Import the Avo library into your code:
SwiftCopy123456789101112131415161718192021222324252627import Avo// An object representing your custom destination// that you pass into initAvo():class CustomDestination : 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:
SwiftCopy12345func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {Avo.initAvo(env: .dev, customDestination: CustomDestination())}
Where customDestination
is the name of the destination in Avo.
Import the Avo library into your code:
JavaCopy1import Avo
Call the initAvo() function:
JavaCopy123456789101112131415161718192021Avo.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}});
KotlinCopy1import Avo
Call the initAvo function:
KotlinCopy123456789101112131415161718192021Avo.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}})
Import the Avo library into your code:
JavaScriptCopy12345678910111213var Avo = require('./Avo.js');// An object representing your custom destination// that you pass into initAvo():var customDestination = {logEvent: async function (userId, eventName, eventProperties) {// TODO implement},setUserProperties: function (userId, userProperties) {// TODO implement},};
If you need to be able to pass an Anonymous Id from the Avo function to your custom destination, reach out to us and we'll enable that functionality for your workspace. When the Anonymous Id pass through has been enabled for your workspace the custom destination interface will look like this:
JavaScriptCopy12345678910var Avo = require('./Avo.js');var customDestination = {logEvent: async function (anonymousId, userId, eventName, eventProperties) {// TODO implement},setUserProperties: function (anonymousId, userId, userProperties) {// TODO implement},};
Call the initAvo() function:
JavaScriptCopy1Avo.initAvo({ env: 'dev' }, {}, {}, customDestination);
By passing in the customDestination
object, its logEvent()
function can be used
to deliver an event to any custom destination or pipeline.
TypeScriptCopy12345678910111213import Avo from './Avo';// An object representing your custom destination// that you pass into initAvo():let customDestination = {logEvent: async function (userId, eventName, eventProperties) {// TODO implement},setUserProperties: function (userId, userProperties) {// TODO implement},};
Call the initAvo function:
TypeScriptCopy1Avo.initAvo({ env: Avo.AvoEnv.Dev }, {}, customDestination);
Import the Avo library into your code:
JavaCopy12import Avo
Call the initAvo() function:
JavaCopy12345678910111213Avo.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}});
PHPCopy1234567891011121314151617require_once './Avo';// An object representing your custom destination// that you pass into initAvo():class CustomDestination {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:
PHPCopy1234Avo::initAvo(['env' => 'dev','customDestinationInstance' => new CustomDestination,]);
Import the Avo library into your code:
PythonCopy123456789101112131415161718from __future__ import print_functionimport avo# An object representing your custom destination# that you pass into init_avo():class CustomDestination(object):def __init__(self):self.env = Nonedef make(self, env):passdef track_event(self, user_id, event_name, event_properties):passdef set_user_properties(self, user_id, user_properties):pass
Call the init_avo() function:
PythonCopy12avo.init_avo(options={'env': 'dev'}, custom_destination=CustomDestination())
where custom_destination
is the name of the custom destination in Avo.
RubyCopy1234567891011121314151617import Avo// An object representing your custom destination// that you pass into initAvo():class CustomDestinationdef make(env:)# TODO implementenddef track_event(anonymous_id:, user_id:, event_name:, event_properties:)# TODO implementenddef set_user_properties(anonymous_id:, user_id:, user_properties:)# TODO implementendend
Call the initAvo function:
RubyCopy1Avo.init_avo(options: {:env => :dev}, custom_destination: CustomDestination.new)
C#Copy1using Avo;
Implement the custom destination:
C#Copy123456789101112131415161718192021class CustomDestination : Avo.IDestination {public void Make(Avo.AvoEnv env) {// TODO implement}public async Task LogEvent(string eventName, IDictionary<string, object> eventProperties) {// TODO implement}public async Task SetUserProperties(string userId, IDictionary<string, object> userProperties) {// TODO implement}public async Task Identify(string userId) {// TODO implement}public async Task Unidentify() {// TODO implement}}
Call the initAvo function:
C#Copy1Avo.initAvo(env=Avo.AvoEnv.Dev, customDestination=new CustomDestination());