### Typewriter Configuration Example Source: https://www.twilio.com/docs/segment/protocols/apis-and-extensions/typewriter Example typewriter.yml configuration showing SDK, language, and tracking plan setup. ```yaml scripts: # You can supply a Segment API token using a `script.token` command. See `Token Script` below. token: source .env; echo $TYPEWRITER_TOKEN # You can format any of Typewriter's auto-generated files using a `script.after` command. # See `Formatting Generated Files` below. after: ./node_modules/.bin/prettier --write analytics/plan.json client: # Which Segment SDK you are generating for. # Valid values: analytics.js, analytics-node, analytics-react-native, swift, kotlin. sdk: analytics-node # The target language for your Typewriter client. # Valid values: javascript, typescript, kotlin, swift. language: typescript trackingPlans: # The Segment Protocols Tracking Plan that you are generating a client for. # Provide your workspace slug and Tracking Plan id, both of which can be found # in the URL when viewing the Tracking Plan editor. For example: # https://app.segment.com/segment-demo/protocols/tracking-plans/rs_QhWHOgp7xg8wkYxilH3scd2uRID # You also need to supply a path to a directory to save your Typewriter client. - id: rs_QhWHOgp7xg8wkYxilH3scd2uRID workspaceSlug: segment-demo path: ./analytics ``` -------------------------------- ### Install analytics-go Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/server/go Install the Segment Go library using the go get command. This is the first step to integrating Segment analytics into your Go application. ```bash go get github.com/segmentio/analytics-go/v3 ``` -------------------------------- ### Initialize Typewriter Wizard Source: https://www.twilio.com/docs/segment/protocols/apis-and-extensions/typewriter Run this command to start the Typewriter quickstart wizard and regenerate configuration files. ```bash npx typewriter init ``` -------------------------------- ### Install SDK via Pod Install Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/leanplum After updating your Podfile, run this command to install the SDK and its dependencies. This command should be executed from your app's directory. ```bash pod install ``` -------------------------------- ### Set App Status to Install Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/moengage Use this method for a fresh installation of your application. This helps differentiate between new installs and updates. ```kotlin MoEAnalyticsHelper.setAppStatus(context, AppStatus.INSTALL) ``` -------------------------------- ### Install JavaNetTrackingPlugin Source: https://www.twilio.com/docs/segment/connections/auto-instrumentation/kotlin-setup Install the `JavaNetTrackingPlugin` where you initialize analytics to enable signal tracking for `java.net.HttpURLConnection`. ```kotlin JavaNetTrackingPlugin.install() ``` -------------------------------- ### SQL Query Example Source: https://www.twilio.com/docs/segment/glossary This is an example of a basic SQL query to retrieve data from a 'users' table. ```sql select * from users where first_name equals "Alice" ``` -------------------------------- ### iOS Library Example Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/optimizely-full-stack Example of how to get a boolean variable from the Optimizely client in the iOS library. Pass `False` to reduce track events if regularly accessing live variables. ```objective-c bool myVariable = [optimizely variableBoolean:@"myVariable" userId:userId] activateExperiment:False]; ``` -------------------------------- ### Track Application Installed Event with URL Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/button Capture application installs and the referring URL using Segment's 'Application Installed' event. This helps in attributing installs to specific campaigns or sources. ```javascript analytics.track('Application Installed' { someProperty: true }, { userId: '1234567890', properties: { url: 'https://brand-homepage.com?btn_ref=srctok-XXX' }, context { app: { version: '4.15.0' }, device: { adTrackingEnabled: false, advertisingId: 'XXXXXXXX-YYYY-ZZZZ-1111-222222222222' }, ip: '127.0.0.1', locale: 'en-US', os: { name: 'iOS', version: '14.2' } } ... }) ``` -------------------------------- ### Basic SDK Setup (Swift) Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/mobile/ios A minimal setup for the Segment Analytics-iOS SDK in Swift, requiring only the write key. ```swift Analytics.setup(with: AnalyticsConfiguration(writeKey: "YOUR_WRITE_KEY")) ``` -------------------------------- ### Client Initialization Configuration Comparison (v2 vs v3) Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/server/go Shows how client configuration options like Interval, BatchSize, and Verbose are applied differently in v2 and v3. v3 uses a `Config` struct during initialization. ```go // Example in v2: client := analytics.New("h97jamjwbh") client.Interval = 30 * time.Second client.Verbose = true client.Size = 100 ``` ```go // Example in v3: client, _ := analytics.NewWithConfig("h97jamjwbh", analytics.Config{ Interval: 30 * time.Second, BatchSize: 100, Verbose: true, }) ``` -------------------------------- ### Install @segment/analytics-next for TypeScript users Source: https://www.twilio.com/docs/segment/protocols/apis-and-extensions/typewriter If you are using the snippet method with TypeScript, install this package as a dev dependency to get TypeScript types. ```sh $ npm install --save-dev @segment/analytics-next ``` -------------------------------- ### MediaMath Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the MediaMath destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/mediamath ### Description Retrieves details and setup instructions for the MediaMath destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/mediamath ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the MediaMath destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the MediaMath destination. - **setup_guide** (string) - Instructions on how to set up the MediaMath destination. #### Response Example ```json { "details": { "name": "MediaMath", "supported_features": [ "Actions" ] }, "setup_guide": "Follow these steps to configure MediaMath..." } ``` ``` -------------------------------- ### Matomo Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Matomo destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/matomo ### Description Retrieves details and setup instructions for the Matomo destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/matomo ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Matomo destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Matomo destination. - **setup_guide** (string) - Instructions on how to set up the Matomo destination. #### Response Example ```json { "details": { "name": "Matomo", "supported_features": [ "Actions", "Traits" ] }, "setup_guide": "Follow these steps to configure Matomo..." } ``` ``` -------------------------------- ### Matcha Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Matcha destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/matcha ### Description Retrieves details and setup instructions for the Matcha destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/matcha ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Matcha destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Matcha destination. - **setup_guide** (string) - Instructions on how to set up the Matcha destination. #### Response Example ```json { "details": { "name": "Matcha", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Matcha..." } ``` ``` -------------------------------- ### Place Visit Event Properties Example Source: https://www.twilio.com/docs/segment/connections/sources/catalog/cloud-apps/foursquare-movement This example demonstrates the structure of a place visit event, showing all available properties and their string-formatted values. Ensure all fields are provided as strings. ```javascript "address": "225 W Ohio St", "city": "Chicago", "confidence": "high", "country": "US", "crossStreet": "", "lat": "41.892114", "lng": "-87.635638", "locationType": "work", "primaryCategoryId": "4bf58dd8d48988d130941735", "primaryCategoryName": "Building", "probability": "0.5112834298670852", "state": "IL", "timestamp": "2020-01-22T15:04:55.000Z", "venueId": "4d21e2ffdd6a236a9c514338", "venueName": "225 West Ohio", "visitId": "5e286497d6d764000801604d", "visitType": "arrival", "zipCode": "60654" ``` -------------------------------- ### Add Multiple Plugins to Segment Client Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/mobile/react-native Demonstrates how to initialize the Segment client and add several pre-built plugins such as Amplitude, Firebase, and Idfa. Ensure necessary packages are installed. ```javascript import { createClient } from '@segment/analytics-react-native'; import { AmplitudeSessionPlugin } from '@segment/analytics-react-native-plugin-amplitude'; import { FirebasePlugin } from '@segment/analytics-react-native-plugin-firebase'; import { IdfaPlugin } from '@segment/analytics-react-native-plugin-idfa'; const segmentClient = createClient({ writeKey: 'SEGMENT_KEY' }); segmentClient.add({ plugin: new AmplitudeSessionPlugin() }); segmentClient.add({ plugin: new FirebasePlugin() }); segmentClient.add({ plugin: new IdfaPlugin() }); ``` -------------------------------- ### Markettailor Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Markettailor destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/markettailor ### Description Retrieves details and setup instructions for the Markettailor destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/markettailor ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Markettailor destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Markettailor destination. - **setup_guide** (string) - Instructions on how to set up the Markettailor destination. #### Response Example ```json { "details": { "name": "Markettailor", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Markettailor..." } ``` ``` -------------------------------- ### Mammoth Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Mammoth destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/mammoth ### Description Retrieves details and setup instructions for the Mammoth destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/mammoth ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Mammoth destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Mammoth destination. - **setup_guide** (string) - Instructions on how to set up the Mammoth destination. #### Response Example ```json { "details": { "name": "Mammoth", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Mammoth..." } ``` ``` -------------------------------- ### Wisepops Website Identifier Setup Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/actions-wisepops This is an example of the HTML script snippet for Wisepops setup, showing where to find the Website Identifier. This identifier is a 10-character string. ```html ``` -------------------------------- ### Configure Client options Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/server/python Create a custom Client instance with various options like debug mode, error handling, send behavior, queue size, upload interval, batch size, and gzip compression. ```python from analytics import Client Client('YOUR_WRITE_KEY', debug=True, on_error=on_error, send=True, max_queue_size=100000, upload_interval=5, upload_size=500, gzip=True) ``` -------------------------------- ### Initialize Segment SDK (Objective-C) Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/mobile/ios Use this snippet to set up the Segment SDK with your write key in Objective-C. Ensure you replace 'YOUR_WRITE_KEY' with your actual Segment source's Write Key. ```objectivec [SEGAnalytics setupWithConfiguration:[SEGAnalyticsConfiguration configurationWithWriteKey:@"YOUR_WRITE_KEY"]]; ``` -------------------------------- ### Identify Call Example Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/tamber An example of an Identify call to Segment, which will be sent to Tamber as a user-update call. Ensure your Segment setup correctly maps user properties. ```javascript analytics.identify('userId123', { age: 23, location: { latitude: 40.8, longitude: -74.0 } }); ``` -------------------------------- ### Mixpanel (Legacy) Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Mixpanel (Legacy) destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/mixpanel ### Description Retrieves details and setup instructions for the Mixpanel (Legacy) destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/mixpanel ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Mixpanel (Legacy) destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Mixpanel (Legacy) destination. - **setup_guide** (string) - Instructions on how to set up the Mixpanel (Legacy) destination. #### Response Example ```json { "details": { "name": "Mixpanel (Legacy)", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Mixpanel (Legacy)..." } ``` ``` -------------------------------- ### Initialize Segment Client in Go Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/server/go Import and initialize the Segment client with your Write Key. Ensure to close the client when done to flush any remaining events. ```go package main import "github.com/segmentio/analytics-go/v3" func main() { client := analytics.New("YOUR_WRITE_KEY") defer client.Close() // Use the client. } ``` -------------------------------- ### Mixpanel (Actions) Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Mixpanel (Actions) destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/actions-mixpanel ### Description Retrieves details and setup instructions for the Mixpanel (Actions) destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/actions-mixpanel ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Mixpanel (Actions) destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Mixpanel (Actions) destination. - **setup_guide** (string) - Instructions on how to set up the Mixpanel (Actions) destination. #### Response Example ```json { "details": { "name": "Mixpanel (Actions)", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Mixpanel (Actions)..." } ``` ``` -------------------------------- ### Full Alias and Track Example in PHP Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/server/php Demonstrates a common workflow where an anonymous user performs actions, is then aliased to an identified user upon signup, and subsequently performs more actions as an identified user. ```php # the anonymous user does actions ... Segment::track(array( "userId" => "anonymous_user", "event" => "Anonymous Event" )); # the anonymous user signs up and is aliased Segment::alias(array( "previousId" => "anonymous_user", "userId" => "identified@example.com" )); # the identified user is identified Segment::identify(array( "userId" => "identified@example.com", "traits" => array( "plan" => "Free" ) )); # the identified user does actions ... Segment::track(array( "userId" => "identified@example.com", "event" => "Identified Action" )); ``` -------------------------------- ### Millennial Media Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Millennial Media destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/millennial-media ### Description Retrieves details and setup instructions for the Millennial Media destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/millennial-media ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Millennial Media destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Millennial Media destination. - **setup_guide** (string) - Instructions on how to set up the Millennial Media destination. #### Response Example ```json { "details": { "name": "Millennial Media", "supported_features": [ "Actions" ] }, "setup_guide": "Follow these steps to configure Millennial Media..." } ``` ``` -------------------------------- ### Metronome (Actions) Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Metronome (Actions) destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/metronome-actions ### Description Retrieves details and setup instructions for the Metronome (Actions) destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/metronome-actions ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Metronome (Actions) destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Metronome (Actions) destination. - **setup_guide** (string) - Instructions on how to set up the Metronome (Actions) destination. #### Response Example ```json { "details": { "name": "Metronome (Actions)", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Metronome (Actions)..." } ``` ``` -------------------------------- ### Marketo V2 Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Marketo V2 destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/marketo-v2 ### Description Retrieves details and setup instructions for the Marketo V2 destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/marketo-v2 ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Marketo V2 destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Marketo V2 destination. - **setup_guide** (string) - Instructions on how to set up the Marketo V2 destination. #### Response Example ```json { "details": { "name": "Marketo V2", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Marketo V2..." } ``` ``` -------------------------------- ### Initialize and Configure Analytics Client Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/mobile/xamarin Instantiate the Analytics client with your Segment write key and optional configuration parameters like flushAt and flushInterval. To make Analytics stateless, add `InMemoryStorageProvider` to the configuration. ```csharp 1 // NOTE: to make Analytics stateless/in-memory, 2 // add `InMemoryStorageProvider` to the configuration var configuration = new Configuration("", flushAt: 20, flushInterval: 30); var analytics = new Analytics(configuration); ``` -------------------------------- ### Android Library Example Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/optimizely-full-stack Example of how to get a boolean variable from the Optimizely client in the Android library. Pass `false` to reduce track events if regularly accessing live variables. ```java Boolean myVariable = optimizelyClient.getVariableBoolean("myVariable", userId, false); ``` -------------------------------- ### Build Production Client with Typewriter Source: https://www.twilio.com/docs/segment/protocols/apis-and-extensions/typewriter Use this command to build a production client with Typewriter. ```bash $ npx typewriter production ``` -------------------------------- ### Load Analytics.js with Asynchronously Fetched Write Key Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/website/javascript This example demonstrates loading analytics.js when the write key is fetched asynchronously. It ensures that the analytics library is properly initialized with the correct write key before any identify calls are made. ```javascript const analytics = new AnalyticsBrowser() fetchWriteKey().then(writeKey => analytics.load({ writeKey })) analytics.identify("hello world") ``` -------------------------------- ### Microsoft Bing CAPI Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Microsoft Bing CAPI destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/microsoft-bing-capi ### Description Retrieves details and setup instructions for the Microsoft Bing CAPI destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/microsoft-bing-capi ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Microsoft Bing CAPI destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Microsoft Bing CAPI destination. - **setup_guide** (string) - Instructions on how to set up the Microsoft Bing CAPI destination. #### Response Example ```json { "details": { "name": "Microsoft Bing CAPI", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Microsoft Bing CAPI..." } ``` ``` -------------------------------- ### Full Alias Call Example in Go Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/server/go Demonstrates a sequence of Segment calls including Track, Alias, Identify, and another Track, showing how to manage user identity transitions from anonymous to identified. ```go // the anonymous user does actions ... client.Enqueue(analytics.Track{ Event: "Anonymous Event", UserId: anonymousUser, }) // the anonymous user signs up and is aliased client.Enqueue(analytics.Alias{ PreviousId: anonymousUser, UserId: "019mr8mf4r", }) // the identified user is identified client.Enqueue(analytics.Identify{ UserId: "019mr8mf4r", Traits: map[string]interface{}{ "name": "Michael Bolton", "email": "mbolton@example.com", "plan": "Enterprise", "friends": 42, }, }) // the identified user does actions ... client.Enqueue(analytics.Track{ Event: "Item Viewed", UserId: "019mr8mf4r", Properties: map[string]interface{}{ "item": "lamp", }, }) ``` -------------------------------- ### Initialize Podfile Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/leanplum Create a podfile in your application's directory using this command. This file is used to manage project dependencies with CocoaPods. ```bash pod init ``` -------------------------------- ### Marketo Static Lists (Actions) Destination Source: https://www.twilio.com/docs/segment/connections/destinations/methods-compare Information and setup guide for the Marketo Static Lists (Actions) destination. ```APIDOC ## GET /websites/twilio_segment/connections/destinations/catalog/actions-marketo-static-lists ### Description Retrieves details and setup instructions for the Marketo Static Lists (Actions) destination. ### Method GET ### Endpoint /websites/twilio_segment/connections/destinations/catalog/actions-marketo-static-lists ### Parameters #### Query Parameters - **destination_id** (string) - Required - The unique identifier for the Marketo Static Lists (Actions) destination. ### Response #### Success Response (200) - **details** (object) - Contains detailed information about the Marketo Static Lists (Actions) destination. - **setup_guide** (string) - Instructions on how to set up the Marketo Static Lists (Actions) destination. #### Response Example ```json { "details": { "name": "Marketo Static Lists (Actions)", "supported_features": [ "Actions", "Traits", "Events" ] }, "setup_guide": "Follow these steps to configure Marketo Static Lists..." } ``` ``` -------------------------------- ### Initialize Segment Client with Configuration Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/server/php Configure the Segment PHP client with your write key and various options like the consumer type, debug mode, SSL usage, and a custom error handler. ```php Segment::init("YOUR_WRITE_KEY", array( "consumer" => "lib_curl", "debug" => true, "ssl" => false, "error_handler" => function ($code, $msg) { [...] } )); ``` -------------------------------- ### Upgrade to Consent Mode v2 for iOS Apps Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/firebase Follow this guide to upgrade your existing consent mode setup to v2 for iOS applications. ```text Upgrade to consent mode v2 for iOS apps ``` -------------------------------- ### Set App Status (Install/Update) in Swift Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/moengage Specify whether the app installation is a new install or an update. This is important for accurate tracking. ```swift //For new Install call following MoEngageSDKAnalytics.sharedInstance.appStatus(.install) //For an app update call following MoEngageSDKAnalytics.sharedInstance.appStatus(.update) ``` -------------------------------- ### Upgrade to Consent Mode v2 for Android Apps Source: https://www.twilio.com/docs/segment/connections/destinations/catalog/firebase Follow this guide to upgrade your existing consent mode setup to v2 for Android applications. ```text Upgrade to consent mode v2 for Android apps ``` -------------------------------- ### Initialize Analytics Client in Kotlin Source: https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/mobile/android Create an analytics client with the given context and Segment write key. Enable automatic tracking of application lifecycle events and screen views. ```kotlin // Create an analytics client with the given context and Segment write key. val analytics = Analytics.Builder(context, YOUR_WRITE_KEY) .trackApplicationLifecycleEvents() // Enable this to record certain application events automatically! .recordScreenViews() // Enable this to record screen views automatically! .build() // Set the initialized instance as a globally accessible instance. Analytics.setSingletonInstance(analytics); ```