### Snowplow CLI Setup Command Example Source: https://docs.snowplow.io/docs/event-studio/programmatic-management/snowplow-cli/reference Examples of how to run the 'snowplow-cli setup' command for device authentication. ```bash $ snowplow-cli setup $ snowplow-cli setup --read-only ``` -------------------------------- ### Start and End HTML5 Media Tracking (npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/html5 This example shows how to start and stop HTML5 media tracking using the npm package. Import the necessary functions before use. ```javascript import { startHtml5MediaTracking, endHtml5MediaTracking } from '@snowplow/browser-plugin-media-tracking' const sessionId = crypto.randomUUID(); startHtml5MediaTracking({ id: "session-id", video: 'html-id', }) // Tracking some video events... endHtml5MediaTracking(sessionId) ``` ```html ``` -------------------------------- ### Quick Start: Track HTML5 Media (JavaScript Tag) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/html5 This example shows how to start tracking HTML5 media using the JavaScript tag. It includes adding the plugin and initiating tracking for a specific video element. ```html ``` ```html ``` -------------------------------- ### Quick Start: Track HTML5 Media (Browser npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/html5 This example demonstrates how to start tracking HTML5 media when using the browser npm package. It imports the necessary function and initiates tracking for a video element. ```javascript import { startHtml5MediaTracking } from '@snowplow/browser-plugin-media-tracking' const sessionId = crypto.randomUUID(); startHtml5MediaTracking({ id: sessionId, video: 'html-id', }) ``` ```html ``` -------------------------------- ### Example GET Request for Social Interaction Source: https://docs.snowplow.io/docs/sources/webhooks/iglu-webhook An example of an Iglu-compatible event sent via a GET request, including optional application ID and platform parameters. ```markup http://{{COLLECTOR_URL}}/com.snowplowanalytics.iglu/v1?schema=iglu%3Acom.snowplowanalytics.snowplow%2Fsocial_interaction%2Fjsonschema%2F1-0-0 &aid=mobile-attribution &p=mob &network=twitter &action=retweet ``` -------------------------------- ### Media Tracking Lifecycle Source: https://docs.snowplow.io/docs/sources/flutter-tracker/tracking-events/media-tracking This example demonstrates the complete lifecycle of media tracking, from starting a session to tracking various events and finally ending the session. ```APIDOC ## Media Tracking Lifecycle ### Description This code snippet illustrates the typical flow for media tracking within a Flutter application. ### Method `tracker.startMediaTracking`, `mediaTracking.update`, `mediaTracking.track`, `tracker.endMediaTracking` ### Code Example ```dart // 1. Start tracking when player loads final id = const Uuid().v4(); MediaTracking mediaTracking = await tracker.startMediaTracking( configuration: MediaTrackingConfiguration( id: id, player: const MediaPlayerEntity( duration: 300, label: 'My Video Title', mediaType: MediaType.video, ) ) ); // 2. Update player state every second await mediaTracking.update( player: MediaPlayerEntity(currentTime: currentTime) ); // 3. Track events as they occur await mediaTracking.track(MediaPlayEvent()); await mediaTracking.track(MediaPauseEvent()); await mediaTracking.track(MediaSeekStartEvent()); await mediaTracking.track(MediaSeekEndEvent()); await mediaTracking.track(MediaEndEvent()); // 4. End tracking when done await tracker.endMediaTracking(id: id); ``` ``` -------------------------------- ### Automated Snowplow CLI Setup Source: https://docs.snowplow.io/docs/event-studio/programmatic-management/snowplow-cli Execute this command for an automated setup process that guides through authentication, API credential creation, and organization ID configuration. ```bash snowplow-cli setup ``` -------------------------------- ### Install Signals Node.js Client Source: https://docs.snowplow.io/docs/signals/connection Install the Signals Node.js client using pnpm. ```bash pnpm i @snowplow/signals-node ``` -------------------------------- ### Start YouTube Tracking (Browser npm - YT.Player) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/youtube Implement YouTube tracking with the YT.Player API using npm modules. This example shows the import and initialization process for a dynamic web application. ```html
``` ```javascript import { newTracker, trackPageView } from '@snowplow/browser-tracker'; import { YouTubeTrackingPlugin, startYouTubeTracking } from '@snowplow/browser-plugin-youtube-tracking'; newTracker('sp1', '{{collector_url}}', { appId: 'my-app-id', plugins: [ YouTubeTrackingPlugin() ], }); const player = new YT.Player('yt-player', { videoId: 'zSM4ZyVe8xs' }); const mediaSessionId = startYouTubeTracking({ id: crypto.randomUUID(), video: player }) endYouTubeTracking(mediaSessionId); ``` -------------------------------- ### Start YouTube Tracking (Browser npm - iFrame) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/youtube Set up YouTube tracking for an iframe using npm. This example demonstrates importing the necessary plugins and functions for a modern JavaScript application. ```html ``` ```javascript import { newTracker, trackPageView } from '@snowplow/browser-tracker'; import { YouTubeTrackingPlugin, startYouTubeTracking } from '@snowplow/browser-plugin-youtube-tracking'; newTracker('sp1', '{{collector_url}}', { appId: 'my-app-id', plugins: [ YouTubeTrackingPlugin() ], }); const mediaSessionId = startYouTubeTracking({ id: crypto.randomUUID(), video: 'yt-player' // or: document.getElementById('yt-player') }) endYouTubeTracking(mediaSessionId); ``` -------------------------------- ### Desktop Context Example Source: https://docs.snowplow.io/docs/sources/c-tracker/initialisation An example of the data structure for the desktop context, which gathers extra device information. ```json { "deviceManufacturer": "Apple Inc.", "deviceModel": "MacPro3,1", "deviceProcessorCount": 8, "osIs64Bit": true, "osServicePack": "", "osType": "macOS", "osVersion": "10.11.2" } ``` -------------------------------- ### Start, Update, and Track Media Events - Android (Java) Source: https://docs.snowplow.io/docs/sources/mobile-trackers/tracking-events/media-tracking Provides a Java example for the media tracking lifecycle on Android. Begin tracking when the player loads, update player state periodically, log media events, and end tracking when finished. Access the default tracker instance. ```java // 1. Start tracking when player loads String id = UUID.randomUUID().toString(); MediaPlayerEntity player = new MediaPlayerEntity(); player.setDuration(300.0); player.setLabel("My Video Title"); player.setMediaType(MediaType.Video); TrackerController tracker = Snowplow.getDefaultTracker(); MediaTracking mediaTracking = tracker.getMedia().startMediaTracking(id, player); // 2. Update player state every second MediaPlayerEntity update = new MediaPlayerEntity(); update.setCurrentTime(currentTime); mediaTracking.update(update, null, null); // 3. Track events as they occur mediaTracking.track(new MediaPlayEvent(), null, null, null); mediaTracking.track(new MediaPauseEvent(), null, null, null); mediaTracking.track(new MediaSeekStartEvent(), null, null, null); mediaTracking.track(new MediaSeekEndEvent(), null, null, null); mediaTracking.track(new MediaEndEvent(), null, null, null); // 4. End tracking when done tracker.getMedia().endMediaTracking(id); ``` -------------------------------- ### API Request Example Source: https://docs.snowplow.io/docs/pipeline/enrichments/available-enrichments/custom-api-request-enrichment An example of an HTTP GET request to an API, including query parameters. ```http GET http://api.acme.com/users/northwind-traders/123?format=json ``` -------------------------------- ### Manually start a new session (JavaScript tag) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/session Use this method to manually expire the current session and start a new one, for example, after a user logs out. ```javascript snowplow('newSession'); ``` -------------------------------- ### Initialize Iglu Server Database Tables Source: https://docs.snowplow.io/docs/api-reference/iglu/iglu-repositories/iglu-server/setup Use the `setup` command with the Iglu Server Docker container to create the necessary database tables. Ensure your `config.hocon` file is correctly mounted. ```bash $ docker run --rm \ -v $PWD/config.hocon:/iglu/config.hocon \ snowplow/iglu-server:0.14.1 setup --config /iglu/config.hocon ``` -------------------------------- ### Initialize Emitter with Minimal Configuration Source: https://docs.snowplow.io/docs/sources/golang-tracker/emitters Initialize an emitter with the collector URI and a storage implementation. This is the most basic setup. ```go emitter := sp.InitEmitter(RequireCollectorUri("com.acme"), sp.RequireStorage(*storagememory.Init())) ``` -------------------------------- ### Generate Data Structure Examples Source: https://docs.snowplow.io/docs/event-studio/programmatic-management/snowplow-cli/reference Examples demonstrating how to generate a new data structure with and without specifying a custom output directory. ```text $ snowplow-cli ds generate my-ds ``` ```text $ snowplow-cli ds generate my-ds ./my-data-structures ``` -------------------------------- ### Install Enhanced Ecommerce Plugin (Browser NPM) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/ecommerce/enhanced Instructions on how to install the enhanced ecommerce plugin using npm or yarn for browser-based projects, along with an example of initializing the tracker with the plugin. ```APIDOC ## Install Enhanced Ecommerce Plugin (Browser NPM) **Browser (npm):** - `npm install @snowplow/browser-plugin-enhanced-ecommerce` - `yarn add @snowplow/browser-plugin-enhanced-ecommerce` - `pnpm add @snowplow/browser-plugin-enhanced-ecommerce` ```javascript import { newTracker, trackPageView } from '@snowplow/browser-tracker'; import { EnhancedEcommercePlugin, trackEnhancedEcommerceAction } from '@snowplow/browser-plugin-enhanced-ecommerce'; newTracker('sp1', '{{collector_url}}', { appId: 'my-app-id', plugins: [ EnhancedEcommercePlugin() ], }); ``` ``` -------------------------------- ### Quick Start Media Tracking Lifecycle Source: https://docs.snowplow.io/docs/sources/flutter-tracker/tracking-events/media-tracking Demonstrates the four main steps of media tracking: starting, updating player state, tracking events, and ending the session. Ensure you have the Uuid package for ID generation. ```dart final id = const Uuid().v4(); MediaTracking mediaTracking = await tracker.startMediaTracking( configuration: MediaTrackingConfiguration( id: id, player: const MediaPlayerEntity( duration: 300, label: 'My Video Title', mediaType: MediaType.video, ) ) ); // 2. Update player state every second await mediaTracking.update( player: MediaPlayerEntity(currentTime: currentTime) ); // 3. Track events as they occur await mediaTracking.track(MediaPlayEvent()); await mediaTracking.track(MediaPauseEvent()); await mediaTracking.track(MediaSeekStartEvent()); await mediaTracking.track(MediaSeekEndEvent()); await mediaTracking.track(MediaEndEvent()); // 4. End tracking when done await tracker.endMediaTracking(id: id); ``` -------------------------------- ### TypeScript Configuration Example Source: https://docs.snowplow.io/docs/event-studio/implement-tracking/configuration-reference Use this TypeScript configuration for Snowtype. Ensure the filename starts with `snowtype.config.ts`. ```typescript const config = { organizationId: "a654321b-c111-33d3-e321-1f123456789g", tracker: "@snowplow/browser-tracker" as const, language: "typescript" as const, outpath: "./src/snowtype", eventSpecificationIds: [ "a123456b-c222-11d1-e123-1f123456789g" ], dataProductIds: [ "a123456b-c222-11d1-e123-1f12345678dp" ], dataStructures: [ "iglu:com.myorg/custom_web_page/jsonschema/1-1-0" ], igluCentralSchemas: [ "iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0" ], repositories: ["../data-structures"], namespace: "Snowtype", options: { commands: { generate: { instructions: true, validations: true, disallowDevSchemas: true }, update: { maximumBump: "minor", showOnlyProdUpdates: true }, patch: { regenerateOnPatch: false } } } }; export default config; ``` -------------------------------- ### JavaScript Configuration Example Source: https://docs.snowplow.io/docs/event-studio/implement-tracking/configuration-reference Use this JavaScript configuration for Snowtype. Ensure the filename starts with `snowtype.config.js`. ```javascript const config = { "organizationId": "a654321b-c111-33d3-e321-1f123456789g", "tracker": "@snowplow/browser-tracker", "language": "typescript", "outpath": "./src/snowtype", "eventSpecificationIds": [ "a123456b-c222-11d1-e123-1f123456789g" ], "dataProductIds": [ "a123456b-c222-11d1-e123-1f12345678dp" ], "dataStructures": [ "iglu:com.myorg/custom_web_page/jsonschema/1-1-0" ], "igluCentralSchemas": [ "iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0" ], "repositories": ["../data-structures"], "namespace": "Snowtype", "options": { "commands": { "generate": { "instructions": true, "validations": true, "disallowDevSchemas": true }, "update": { "maximumBump": "minor", "showOnlyProdUpdates": true }, "patch": { "regenerateOnPatch": false } } } }; module.exports = config; ``` -------------------------------- ### Example: Enable YouTube Tracking (npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/youtube An example of enabling YouTube tracking using npm, specifying a custom label, capture events, and progress boundaries. ```javascript enableYouTubeTracking({ id: 'example-video', options: { label: 'My Custom Video Label', captureEvents: ['play', 'pause', 'ended'], boundaries: [20, 80], updateRate: 200, } }) ``` -------------------------------- ### Initialize Emitter with Full Configuration Source: https://docs.snowplow.io/docs/sources/golang-tracker/emitters Initialize an emitter with all available options, including request type, protocol, send limits, byte limits, and a custom callback function for delivery status. ```go emitter := sp.InitEmitter( sp.RequireCollectorUri("com.acme"), sp.RequireStorage(*storagememory.Init()), sp.OptionRequestType("GET"), sp.OptionProtocol("https"), sp.OptionSendLimit(50), sp.OptionByteLimitGet(52000), sp.OptionByteLimitPost(52000), sp.OptionCallback(func(g []CallbackResult, b []CallbackResult) { log.Println("Successes: " + IntToString(len(g))) log.Println("Failures: " + IntToString(len(b))) }), ) ``` -------------------------------- ### Start AVPlayer Media Tracking (iOS) Source: https://docs.snowplow.io/docs/sources/mobile-trackers/tracking-events/media-tracking Pass your AVPlayer instance and a media tracking configuration to start automatic event tracking. This setup enables the tracker to capture various playback events. ```swift let mediaTracking = tracker.media.startMediaTracking( player: avPlayer, configuration: MediaTrackingConfiguration(id: "my-video") ) ``` -------------------------------- ### Initialize and Start .NET Tracker Source: https://docs.snowplow.io/docs/sources/net-tracker/tracker Configure the .NET tracker instance with emitter, subject, session, and logging options. Ensure to dispose of storage manually after stopping the tracker. ```csharp var logger = new ConsoleLogger(); var endpoint = new SnowplowHttpCollectorEndpoint(emitterUri, method: method, port: port, protocol: protocol, l: logger); var storage = new LiteDBStorage("events.db"); var queue = new PersistentBlockingQueue(storage, new PayloadToJsonString()); var emitter = new AsyncEmitter(endpoint, queue, l: logger); var subject = new Subject().SetPlatform(Platform.Mob).SetLang("EN"); var session = new ClientSession("client_session.dict", l: logger); Tracker.Instance.Start(emitter: emitter, subject: subject, clientSession: session, trackerNamespace: "some namespace", appId: "some appid", encodeBase64: true, l: logger); ``` -------------------------------- ### Install Go Analytics SDK Source: https://docs.snowplow.io/docs/api-reference/analytics-sdk/analytics-sdk-go Use 'go get' to add the Snowplow Analytics SDK for Go to your project. ```bash go get github.com/snowplow/snowplow-golang-analytics-sdk ``` -------------------------------- ### Initialize Terraform and Plan Changes for Iglu Server Source: https://docs.snowplow.io/docs/get-started/self-hosted/upgrade-guide Navigate to the Iglu Server Terraform configuration directory and run 'terraform init' to initialize the backend and download providers. 'terraform plan' will show the infrastructure changes before applying them. ```bash cd terraform/aws/iglu_server/default terraform init terraform plan ``` -------------------------------- ### Clone repo and start Snowplow Micro with Docker Compose Source: https://docs.snowplow.io/docs/testing/snowplow-micro/automated-testing Clone the example repository, navigate into it, and start Snowplow Micro using Docker Compose. This command launches the application and Snowplow Micro, mounting necessary configuration files. ```bash git clone https://github.com/snowplow-incubator/snowplow-micro-examples.git cd snowplow-micro-examples docker-compose up ``` -------------------------------- ### Run Snowplow Micro with Help Source: https://docs.snowplow.io/docs/api-reference/snowplow-micro Use the `--help` argument to discover all supported options for Snowplow Micro. ```bash docker run -p 9090:9090 snowplow/snowplow-micro:4.2.0 --help ``` -------------------------------- ### Query seek_start_event Source: https://docs.snowplow.io/docs/events/ootb-data/media-events Example Snowflake query to retrieve seek start events. Filters events within the last hour. ```sql select unstruct_event_com_snowplowanalytics_snowplow_media_seek_start_event_1 seek_start_event_1 from atomic.events where events.collector_tstamp > getdate() - interval '1 hour' and events.event = 'unstruct' and events.event_name = 'seek_start_event' and events.event_vendor = 'com.snowplowanalytics.snowplow.media' ``` -------------------------------- ### Configuration for startMediaTracking Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/snowplow Details on how to configure player properties when initiating media tracking. ```APIDOC ## Configuration Configure media tracking when you call `startMediaTracking`. All configuration is optional. ### Player properties Set initial player properties to populate the [media player entity](/docs/events/ootb-data/media-events/#media-player). The `label` property is recommended as it helps identify content during analysis. **JavaScript (tag):** ```javascript window.snowplow('startMediaTracking', { id, player: { currentTime: 0, // Current playback position in seconds duration: 300, // Total duration in seconds ended: false, // Whether playback has ended livestream: false, // Whether this is a live stream label: 'My Video', // Human-readable title (recommended) loop: false, // Whether to restart after ending mediaType: 'video', // 'video' or 'audio' muted: false, // Whether audio is muted paused: true, // Whether playback is paused pictureInPicture: false, // Whether in picture-in-picture mode playerType: 'html5', // Player type identifier playbackRate: 1.0, // Playback speed (1 = normal) quality: '1080p', // Quality level volume: 100 // Volume percentage (0-100) } }); ``` **Browser (npm):** ```javascript import { startMediaTracking, MediaType } from "@snowplow/browser-plugin-media"; startMediaTracking({ id, player: { currentTime: 0, // Current playback position in seconds duration: 300, // Total duration in seconds ended: false, // Whether playback has ended livestream: false, // Whether this is a live stream label: 'My Video', // Human-readable title (recommended) loop: false, // Whether to restart after ending mediaType: MediaType.Video, // MediaType.Video or MediaType.Audio muted: false, // Whether audio is muted paused: true, // Whether playback is paused pictureInPicture: false, // Whether in picture-in-picture mode playerType: 'html5', // Player type identifier playbackRate: 1.0, // Playback speed (1 = normal) quality: '1080p', // Quality level volume: 100 // Volume percentage (0-100) } }); ``` ``` -------------------------------- ### Direct Tracker, Emitter, and ClientSession Initialization Source: https://docs.snowplow.io/docs/sources/c-tracker/initialisation Instantiate and configure storage, emitter, subject, client session, and tracker components directly. This approach is suitable for custom implementations or when fine-grained control is needed. ```cpp #include // 1. create storage for event queue and session information auto storage = std::make_shared("sp.db"); // 2. create an emitter for sending event to Snowplow collector auto emitter = std::make_shared(storage, "com.acme.collector"); // 3. create a subject with user and device information auto subject = std::make_shared(); subject->set_user_id("a-user-id"); // 4. optionally create a client_session for session tracking auto client_session = std::make_shared(storage, 5000, 5000); // 5. finally, create the tracker instance auto tracker = std::make_shared(emitter, subject, client_session, "pc", "app_id", "ns"); ``` -------------------------------- ### Converted Self-Describing JSON Event Source: https://docs.snowplow.io/docs/sources/webhooks/iglu-webhook The resulting self-describing JSON event after being processed by the Iglu webhook adapter from the example GET request. ```json { "schema":"iglu:com.snowplowanalytics.snowplow/social_interaction/jsonschema/1-0-0", "data": { "network": "twitter", "action": "retweet" } } ``` -------------------------------- ### Adjust Webhook URL Configuration Source: https://docs.snowplow.io/docs/sources/webhooks/adjust-webhook Use this URL in Adjust's event settings to send install data to your Snowplow collector. Ensure you replace 'mycollector.mydomain.com' with your actual collector URL. This example includes all available Adjust placeholders for install events. ```markup http://mycollector.mydomain.com/com.snowplowanalytics.iglu/v1?schema=iglu%3Acom.adjust%2Finstall%2Fjsonschema%2F1-0-0&app_id={app_id}&app_name={app_name}&app_name_dashboard={app_name_dashboard}&store={store}&tracker={tracker}&tracker_name={tracker_name}&network_name={network_name}&campaign_name={campaign_name}&adgroup_name={adgroup_name}&creative_name={creative_name}&impression_based={impression_based}&is_organic={is_organic}&gclid={gclid}&rejection_reason={rejection_reason}&click_referer={click_referer}&click_attribution_window={click_attribution_window}&impression_attribution_window={impression_attribution_window}&reattribution_attribution_window={reattribution_attribution_window}&inactive_user_definition={inactive_user_definition}&adid={adid}&idfa={idfa}&android_id={android_id}&android_id_md5={android_id_md5}&mac_sha1={mac_sha1}&mac_md5={mac_md5}&idfa-android-id={idfa||android_id}&idfa-or-gps-adid={idfa||gps_adid}&idfa_md5={idfa_md5}&idfa_md5_hex={idfa_md5_hex}&idfv={idfv}&gps_adid={gps_adid}&gps_adid_md5={gps_adid_md5}&win_udid={win_udid}&win_hwid={win_hwid}&win_naid={win_naid}&win_adid={win_adid}&match_type={match_type}&reftag={reftag}&referrer={referrer}&user_agent={user_agent}&ip_address={ip_address}&click_time={click_time}&engagement_time={engagement_time}&installed_at={installed_at}&installed_at_hour={installed_at_hour}&created_at={created_at}&reattributed_at={reattributed_at}&connection_type={connection_type}&isp={isp}&city={city}&country={country}&language={language}&device_name={device_name}&device_type={device_type}&os_name={os_name}&api_level={api_level}&sdk_version={sdk_version}&os_version={os_version}&environment={environment}&tracking_enabled={tracking_enabled}&timezone={timezone}&fb_campaign_group_name={fb_campaign_group_name}&fb_campaign_group_id={fb_campaign_group_id}&fb_campaign_name={fb_campaign_name}&fb_campaign_id={fb_campaign_id}&fb_adgroup_name={fb_adgroup_name}&fb_adgroup_id={fb_adgroup_id}&tweet_id={tweet_id}&twitter_line_item_id={twitter_line_item_id}&label={label} ``` -------------------------------- ### Initialize Tracker with Optional Configurations Source: https://docs.snowplow.io/docs/sources/golang-tracker/initialization Initialize a tracker with optional configurations including subject, namespace, app ID, platform, and base64 encoding. ```go subject := sp.InitSubject() emitter := sp.InitEmitter( sp.RequireCollectorUri("com.acme"), sp.RequireStorage(*storagememory.Init()), ) tracker := sp.InitTracker( sp.RequireEmitter(emitter), sp.OptionSubject(subject), sp.OptionNamespace("namespace"), sp.OptionAppId("app-id"), sp.OptionPlatform("mob"), sp.OptionBase64Encode(false), ) ``` -------------------------------- ### Run Snowtype executable Source: https://docs.snowplow.io/docs/event-studio/implement-tracking/install-snowtype Execute the locally installed Snowtype CLI to view available commands and options. This example uses npx, but yarn or pnpm can also be used. ```bash npx snowtype --help ``` -------------------------------- ### Example Iglu Central mirror URL Source: https://docs.snowplow.io/docs/api-reference/iglu/iglu-central-setup This is an example of how your Iglu Central mirror URL might look after setting up a static repository. ```text http://iglucentral.acme.com ``` -------------------------------- ### Start Element Tracking (npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/element-tracking After initializing the tracker with the plugin, call startElementTracking to begin monitoring elements based on your defined rules. ```javascript startElementTracking({ elements: [/* configuration */] }); ``` -------------------------------- ### Initialize Tracker with Ecommerce Plugin (npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/ecommerce Initialize the Snowplow tracker with the ecommerce plugin when installing via npm. This example shows the import and configuration for a new tracker instance. ```javascript import { newTracker } from '@snowplow/browser-tracker'; import { SnowplowEcommercePlugin } from '@snowplow/browser-plugin-snowplow-ecommerce'; newTracker('sp1', '{{collector_url}}', { appId: 'my-app-id', plugins: [ SnowplowEcommercePlugin() ], }); ``` -------------------------------- ### Create Tracker with All Arguments Source: https://docs.snowplow.io/docs/sources/php-tracker/initialization Initialize a Tracker instance using all available arguments: emitter, subject, namespace, application ID, and base64 encoding preference. ```php $tracker = new Tracker($emitter, $subject, "cf", "cf29ea", true); ``` -------------------------------- ### Initialize Tracker with Emitter and Storage Source: https://docs.snowplow.io/docs/sources/golang-tracker/initialization Create a basic tracker instance by initializing an emitter with a collector URI and an in-memory storage implementation. ```go import storagememory "github.com/snowplow/snowplow-golang-tracker/v3/pkg/storage/memory" import sp "github.com/snowplow/snowplow-golang-tracker/v3/tracker" emitter := sp.InitEmitter(sp.RequireCollectorUri("com.acme"), sp.RequireStorage(*storagememory.Init())) tracker := sp.InitTracker(sp.RequireEmitter(emitter)) ``` -------------------------------- ### Start Element Tracking with Browser Plugin (npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/element-tracking Install and use the element tracking plugin via npm for your browser-based JavaScript applications. This provides a modular way to add element tracking functionality. ```javascript import { startElementTracking } from '@snowplow/browser-plugin-element-tracking'; startElementTracking({ elements: [ { selector: ".blogs_blog-post-body_content", name: "blog content", expose: false, includeStats: ["page_ping"] }, { selector: ".blogs_blog-post-body_content p", name: "blog paragraphs" } ] }); ``` -------------------------------- ### Initialize Tracker with Client Hints Plugin (Basic) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/client-hints When using npm or yarn, import and initialize the tracker with the Client Hints plugin. This configuration captures basic client hints. ```javascript import { newTracker } from '@snowplow/browser-tracker'; import { ClientHintsPlugin } from '@snowplow/browser-plugin-client-hints'; // Basic newTracker('sp1', '{{collector_url}}', { appId: 'my-app-id', plugins: [ ClientHintsPlugin() ], }); ``` -------------------------------- ### Add Context Entities to Screen View (npm) Source: https://docs.snowplow.io/docs/sources/webview-tracker Add context entities to a screen view event when installed via npm. This example adds two custom entities for movie poster and customer data. ```javascript trackScreenView({ id: '2c295365-eae9-4243-a3ee-5c4b7baccc8f', context: [ { schema: 'iglu:com.my_company/movie_poster/jsonschema/1-0-0', data: { movie_name: 'Solaris', poster_country: 'JP', poster_date: '1978-01-01', }, }, { schema: 'iglu:com.my_company/customer/jsonschema/1-0-0', data: { p_buy: 0.23, segment: 'young_adult', }, }, ], }); ``` -------------------------------- ### Initialize Terraform and Plan Changes for Pipeline Source: https://docs.snowplow.io/docs/get-started/self-hosted/upgrade-guide Navigate to the Pipeline Terraform configuration directory and run 'terraform init' to initialize the backend and download providers. 'terraform plan' will show the infrastructure changes before applying them. ```bash cd terraform/aws/pipeline/default terraform init terraform plan ``` -------------------------------- ### Inline Plugin: Add Context Entities (NPM) Source: https://docs.snowplow.io/docs/sources/web-trackers/plugins/creating-your-own-plugins Shows how to define and add an inline plugin using the Snowplow JavaScript Tracker when installed via NPM. This example adds a custom context entity to all events. ```javascript import { addPlugin } from '@snowplow/browser-tracker'; const myPlugin = { contexts: () => { return [ { schema: 'iglu:com.acme/my_context/jsonschema/1-0-0', data: { property: 'value', }, }, ]; }, }; addPlugin(myPlugin, ['sp1']) ``` -------------------------------- ### Initialize Tracker v1.0.0 Source: https://docs.snowplow.io/docs/sources/react-native-tracker/migration-guides/migrating-from-v0-x-to-v1 Example of creating a tracker with required arguments in v1.0.0, including NetworkConfiguration and TrackerControllerConfiguration. ```typescript import { createTracker } from '@snowplow/react-native-tracker'; const tracker = createTracker( 'my-tracker-namespace', { endpoint: 'my-endpoint.com', }, { trackerConfig: { appId: 'my-app-id' } } ); ``` -------------------------------- ### Start Element Tracking with Components (Browser Plugin) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/element-tracking Use this to mark elements as components and track other elements within them. Events for child elements will include a `component_parents` entity listing their ancestor components. Requires installation of `@snowplow/browser-plugin-element-tracking`. ```javascript import { SnowplowElementTrackingPlugin, startElementTracking } from '@snowplow/browser-plugin-element-tracking'; startElementTracking({ elements: [ // Define components (containers) { selector: 'header', // Mark the header as a component name: 'site_header', component: true, expose: false // Don't track expose events for the component itself }, { selector: 'footer', // Mark the footer as a component name: 'site_footer', component: true, expose: false // Don't track expose events for the component itself }, // Track elements - events will include component_parents { selector: '.newsletter-form', name: 'newsletter_signup', create: true, // Fire create_element events expose: { when: 'element' } // Fire expose_element events } ] }); ``` -------------------------------- ### Run Stream Collector with TLS Enabled Source: https://docs.snowplow.io/docs/api-reference/stream-collector/configure Start the Snowplow Scala Stream Collector in a Docker container, mounting configuration and SSL directories. This example configures the collector to use the generated PKCS12 certificate for TLS on port 8443. ```bash config_dir=/opt/snowplow/config docker run \ -d \ --name scala-stream-collector \ --restart always \ --network host \ -v ${config_dir}:/snowplow/config \ -v ${ssl_dir}:/snowplow/ssl \ -p 8080:8080 \ -p 8443:8443 \ -e 'JAVA_OPTS=-Xms2g -Xmx2g -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=changeme -Djavax.net.ssl.keyStore=/snowplow/ssl/collector.p12 -Dorg.slf4j.simpleLogger.defaultLogLevel=warn -Dcom.amazonaws.sdk.disableCbor' \ snowplow/scala-stream-collector-kinesis:2.5.0 \ --config /snowplow/config/snowplow-stream-collector-kinesis-2.5.0.hocon ``` -------------------------------- ### Enable activity tracking with example values (Browser npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/activity-page-pings Example of enabling activity tracking with `minimumVisitLength` set to 30 seconds and `heartbeatDelay` to 10 seconds using the browser tracker (npm). Call `enableActivityTracking` before `trackPageView`. ```javascript import { enableActivityTracking, trackPageView } from '@snowplow/browser-tracker'; enableActivityTracking({ minimumVisitLength: 30, heartbeatDelay: 10 }); trackPageView(); ``` -------------------------------- ### Start HTML5 Media Tracking with Browser (npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/html5 Initiate HTML5 media tracking using the npm package. This method requires direct access to the video element via `document.getElementById` or a similar DOM manipulation method. ```javascript startHtml5MediaTracking({ id: "unique-session-id", video: document.getElementById("myVideoElement"), label: "Product Demo Video", captureEvents: ["play", "pause", "end"], boundaries: [25, 50, 75, 100], pings: { pingInterval: 20, maxPausedPings: 2, }, updatePageActivityWhilePlaying: true, filterOutRepeatedEvents: { seekEvents: true, volumeChangeEvents: false, flushTimeoutMs: 5000 }, session: { // Custom session start time startedAt: new Date('2024-01-01T12:00:00Z'), }, }); ``` -------------------------------- ### Add YouTube Tracking Plugin and Track Custom Event (Browser NPM) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracking-events/media/youtube This example demonstrates how to set up the YouTube tracking plugin and track a custom self-describing event using the Snowplow browser tracker with npm. It initializes the tracker, starts and ends the YouTube tracking session, and tracks a custom event. ```html ``` ```javascript import { newTracker, trackPageView } from '@snowplow/browser-tracker'; import { YouTubeTrackingPlugin, endYouTubeTracking, startYouTubeTracking } from '@snowplow/browser-plugin-youtube-tracking'; newTracker('sp1', '{{collector_url}}', { appId: 'my-app-id', plugins: [ YouTubeTrackingPlugin() ], }); const mediaSessionId = startYouTubeTracking({ id: crypto.randomUUID(), video: 'yt-player' // or: document.getElementById('yt-player') }); trackYouTubeSelfDescribingEvent({event: {schema: 'iglu:com_example/my_event/jsonschema/1-0-0', data: { video: true }}}); endYouTubeTracking(mediaSessionId); ``` -------------------------------- ### Enable Automatic Application Install Events Source: https://docs.snowplow.io/docs/sources/roku-tracker/tracking-events Configure the tracker to automatically send an `application_install` event upon the first user ID generation. This is useful for tracking new installations and app lifecycle events. ```brightscript m.global.snowplow.init = { trackInstall: true } ``` -------------------------------- ### Tracker Start Source: https://docs.snowplow.io/docs/sources/net-tracker/tracker The `Start(...)` function must be called before any events will start being stored or sent. This function starts the background emitter thread and the background session check timer (if optional). ```APIDOC ## Start(...) ### Description This function must be called before any events will start being stored or sent. This is due to the fact that we do not want to start any background processing from the constructors so it is left up to the developer to choose when to start everything up. If you attempt to access the Tracker singleton before Starting it an exception will be thrown. This function: - Starts the background emitter thread - Starts the background session check timer (Optional) Once this is run everything should be in place for asynchronous event tracking. ### Parameters #### Path Parameters - **emitter** (Emitter) - Required - The Emitter object you create. - **subject** (Subject) - Optional - The Subject that defines a user. - **clientSession** (Session) - Optional - The Session object you create. - **trackerNamespace** (string) - Optional - The name of the tracker instance. - **appId** (string) - Optional - The application ID. - **encodeBase64** (bool) - Optional - If we base 64 encode JSON values. - **l** (Logger) - Optional - The logger to use within the application. ``` -------------------------------- ### Install Snowplow Normalize Python Dependencies Source: https://docs.snowplow.io/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-quickstart/normalize Install the required Python packages for the Snowplow Normalize package using pip. This command installs packages listed in the requirements.txt file. ```bash pip install -r dbt_packages/snowplow_normalize/utils/requirements.txt ``` -------------------------------- ### Snowplow CLI Data Structures Download Examples Source: https://docs.snowplow.io/docs/event-studio/programmatic-management/snowplow-cli/reference Examples demonstrating how to download data structures using the Snowplow CLI. Includes basic download, matching specific patterns, custom output formats, and including legacy structures. ```bash snowplow-cli ds download ``` ```bash snowplow-cli ds download --match com.example/event_name --match com.example.subdomain ``` ```bash snowplow-cli ds download --output-format json ./my-data-structures ``` ```bash snowplow-cli ds download --include-legacy ``` -------------------------------- ### Install Snowplow Ecommerce Plugin via npm/yarn/pnpm Source: https://docs.snowplow.io/docs/collecting-data/collecting-from-own-applications/javascript-trackers/web-tracker/plugins/snowplow-ecommerce Install the Snowplow Ecommerce plugin using your preferred package manager. This is for use with the browser tracker when installed via npm. ```javascript import { newTracker } from '@snowplow/browser-tracker'; import { SnowplowEcommercePlugin } from '@snowplow/browser-plugin-snowplow-ecommerce'; newTracker('sp1', '{{collector_url}}', { appId: 'my-app-id', plugins: [ SnowplowEcommercePlugin() ], }); ``` -------------------------------- ### Install Snowplow Tracker with LuaRocks Source: https://docs.snowplow.io/docs/sources/lua-tracker Install the Snowplow tracker using LuaRocks. Ensure Lua, LuaRocks, and curl are installed. You may need to specify the CURL_DIR if curl is not found automatically. ```bash luarocks install snowplowtracker ``` ```bash luarocks install snowplowtracker CURL_DIR=/usr/local/Cellar/curl/7.82.0/ ``` -------------------------------- ### Igluctl Static Deploy Configuration Example Source: https://docs.snowplow.io/docs/api-reference/iglu/igluctl-2 Example HOCON configuration file for `igluctl static deploy`. Supports linting, schema generation, and actions like push or S3 copy. ```json { "lint": { "skipWarnings": true "includedChecks": [ "rootObject" "unknownFormats" "numericMinMax" "stringLength" "optionalNull" "description" "stringMaxLengthRange" ] } "generate": { "dbschema": "atomic" "force": false } "actions": [ { "action": "push" "isPublic": true "apikey": "bd96b5ff-7eb7-4085-83e0-97ac4954b891" "apikey": ${APIKEY_1} } { "action": "s3cp" "uploadFormat": "jsonschema" "profile": "profile-1" "region": "eu-east-2" } ] } ``` -------------------------------- ### Construct a Tracker instance Source: https://docs.snowplow.io/docs/sources/unity-tracker/tracker Instantiate a Tracker with emitter, namespace, app ID, subject, session, platform, and base64 encoding settings. Ensure all required arguments are provided. ```csharp IEmitter e1 = new AsyncEmitter ("com.collector.acme") Subject subject = new Subject(); Session session = new Session(null); Tracker t1 = new Tracker(e1, "Namespace", "AppId", subject, session, DevicePlatforms.Desktop, true); ``` -------------------------------- ### Full Tracker Initialization - Browser (npm) Source: https://docs.snowplow.io/docs/sources/web-trackers/tracker-setup/initialization-options This example demonstrates initializing the Snowplow tracker using the Browser (npm) integration, setting all available configuration options. Note that the `contexts.session` and `contexts.browser` options are off by default and require specific versions. ```javascript newTracker('sp', '{{collector_url_here}}', { appId: 'my-app-id', appVersion: '0.1.0', platform: 'web', cookieDomain: null, discoverRootDomain: true, cookieName: '_sp_', cookieSameSite: 'Lax', // Recommended cookieSecure: true, encodeBase64: true, respectDoNotTrack: false, eventMethod: 'post', bufferSize: 1, maxPostBytes: 40000, maxGetBytes: 1000, // available in v3.4+ postPath: '/custom/path', // Collector must be configured crossDomainLinker: function (linkElement) { return (linkElement.href === 'http://acme.de' || linkElement.id === 'crossDomainLink'); }, useExtendedCrossDomainLinker: { userId: true, }, cookieLifetime: 63072000, sessionCookieTimeout: 1800, stateStorageStrategy: 'cookieAndLocalStorage', maxLocalStorageQueueSize: 1000, resetActivityTrackingOnPageView: true, connectionTimeout: 5000, anonymousTracking: false, // anonymousTracking: { withSessionTracking: true }, // anonymousTracking: { withSessionTracking: true, withServerAnonymisation: true }, customHeaders: {}, // Use with caution. Available from v3.2.0+ credentials: 'include', // Available from v4+ contexts: { webPage: true, // Default session: false, // Adds client session context entity to events, off by default. Available in v3.5+. browser: false // Adds browser context entity to events, off by default. Available in v3.9+. }, plugins: [], retryStatusCodes: [], dontRetryStatusCodes: [], retryFailedRequests: true, onSessionUpdateCallback: function(clientSession) { }, // Allows the addition of a callback, whenever a new session is generated. Available in v3.11+. onRequestSuccess: function(data) => { }, // Available in v3.18.1+ onRequestFailure: function(data) => { }, // Available in v3.18.1+ ``` -------------------------------- ### Example User-Agent String Source: https://docs.snowplow.io/docs/enriching-your-data/available-enrichments/ua-parser-enrichment This is an example of a User-Agent string that can be parsed by the UA Parser enrichment. ```text Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36 ```