### Dub Analytics Installation Guides Source: https://dub.co/docs/conversions/leads/clerk Links to various guides for installing the Dub Analytics script on different platforms. ```APIDOC ## Client-Side Installation ### Description Guides for installing the `@dub/analytics` script on your website to track conversion events. ### Installation Options - **React**: [Link to React installation guide](/sdks/client-side/installation-guides/react) - **Manual Installation**: [Link to manual installation guide](/sdks/client-side/installation-guides/manual) - **Framer**: [Link to Framer installation guide](/sdks/client-side/installation-guides/framer) - **Shopify**: [Link to Shopify installation guide](/sdks/client-side/installation-guides/shopify) - **WordPress**: [Link to WordPress installation guide](/sdks/client-side/installation-guides/wordpress) - **Webflow**: [Link to Webflow installation guide](/sdks/client-side/installation-guides/webflow) - **Google Tag Manager**: [Link to Google Tag Manager installation guide](/sdks/client-side/installation-guides/google-tag-manager) ``` -------------------------------- ### Client-Side Installation Guides Source: https://dub.co/docs/conversions/leads/appwrite Various guides for installing the Dub Analytics script on the client-side, including React, manual installation, Framer, Shopify, WordPress, Webflow, and Google Tag Manager. ```APIDOC ## Client-Side Installation Guides ### Description This section provides links to detailed guides on how to install the `@dub/analytics` script on your website for tracking conversion events. Choose the guide that best suits your website's technology stack. ### Available Guides * **React**: [Link to React installation guide](/sdks/client-side/installation-guides/react) * **Manual Installation**: [Link to manual installation guide](/sdks/client-side/installation-guides/manual) * **Framer**: [Link to Framer installation guide](/sdks/client-side/installation-guides/framer) * **Shopify**: [Link to Shopify installation guide](/sdks/client-side/installation-guides/shopify) * **WordPress**: [Link to WordPress installation guide](/sdks/client-side/installation-guides/wordpress) * **Webflow**: [Link to Webflow installation guide](/sdks/client-side/installation-guides/webflow) * **Google Tag Manager**: [Link to Google Tag Manager installation guide](/sdks/client-side/installation-guides/google-tag-manager) ``` -------------------------------- ### Install Dub Go SDK Source: https://dub.co/docs/sdks/go This command installs the Dub Go SDK using the go get command. Ensure you have Go installed and configured. ```bash go get github.com/dubinc/dub-go ``` -------------------------------- ### Create Link with Dub.co SDKs (Python, Go, Ruby) Source: https://dub.co/docs/conversions/leads/appwrite Demonstrates how to create a link using the Dub.co SDK in Python, Go, and Ruby. These examples show the basic usage for creating a link with a URL and enabling conversion tracking. Ensure the respective SDKs are installed and configured. ```python link = d.links.create(url="https://dub.co", track_conversion=True) ``` ```go link, err := d.Links.Create(ctx, &dub.CreateLinkRequest{ URL: "https://dub.co", TrackConversion: true, }) ``` ```ruby s.links.create_many( ::OpenApiSDK::Operations::CreateLinkRequest.new( url: "https://dub.co", track_conversion: true, ) ) ``` -------------------------------- ### Create Link with Conversion Tracking (JavaScript, Python, Go, Ruby) Source: https://dub.co/docs/conversions/leads/clerk Demonstrates creating a link with conversion tracking enabled using Dub.co's SDKs in JavaScript, Python, Go, and Ruby. Ensure the respective SDKs are installed and initialized before use. These examples show the basic structure for creating a link and setting the `trackConversion` or equivalent property. ```javascript const d = new Dub("YOUR_API_KEY"); d.links.create({ url: "https://dub.co", trackConversion: true, }); ``` ```python link = d.links.create(url="https://dub.co", track_conversion=True) ``` ```go link, err := d.Links.Create(ctx, &dub.CreateLinkRequest{ URL: "https://dub.co", TrackConversion: true, }) ``` ```ruby s.links.create_many( ::OpenApiSDK::Operations::CreateLinkRequest.new( url: "https://dub.co", track_conversion: true, ) ) ``` -------------------------------- ### Setup Verification Source: https://dub.co/docs/sdks/client-side/features/click-tracking Steps to verify that the client-side click tracking is functioning correctly after setup. ```APIDOC ## Verify Setup ### Description Verify that your click-tracking is working by running your website locally and appending the URL with the unique key of your short link. Check for successful `/track/click` requests, the presence of the `dub_id` cookie, and accurate tracking in the Dub workspace. ### Method N/A (Verification steps) ### Endpoint N/A (Verification steps) ### Parameters N/A ### Request Example Append `?via=abc123` to your short link URL, e.g., `https://go.example.com/abc123?via=abc123`. ### Response N/A ### Verification Checklist 1. A successful `/track/click` request is visible in your browser's **Network** tab. 2. The `dub_id` cookie is set upon a successful `/track/click` request. 3. The click is tracked correctly in the **Events** tab of your Dub workspace. ``` -------------------------------- ### Go SDK Example Source: https://dub.co/docs/conversions/leads/appwrite Example of creating a link with conversion tracking enabled using the Go SDK. ```APIDOC ## Go SDK Example ### Description This code snippet demonstrates how to create a new link with conversion tracking enabled using the Dub Go SDK. ### Method `d.Links.Create()` ### Endpoint N/A (Server-side SDK) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **URL** (string) - Required - The destination URL for the link. * **TrackConversion** (boolean) - Optional - Set to `true` to enable conversion tracking for this link. ### Request Example ```go link, err := d.Links.Create(ctx, &dub.CreateLinkRequest{ URL: "https://dub.co", TrackConversion: true, }) ``` ### Response #### Success Response (200) Returns a link object upon successful creation. #### Response Example ```json { "id": "clnk_abc123", "url": "https://dub.co", "track_conversion": true } ``` ``` -------------------------------- ### Ruby SDK Example Source: https://dub.co/docs/conversions/leads/appwrite Example of creating a link with conversion tracking enabled using the Ruby SDK. ```APIDOC ## Ruby SDK Example ### Description This code snippet shows how to create a new link with conversion tracking enabled using the Dub Ruby SDK. ### Method `s.links.create_many()` ### Endpoint N/A (Server-side SDK) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **url** (string) - Required - The destination URL for the link. * **track_conversion** (boolean) - Optional - Set to `true` to enable conversion tracking for this link. ### Request Example ```ruby s.links.create_many( ::OpenApiSDK::Operations::CreateLinkRequest.new( url: "https://dub.co", track_conversion: true, ) ) ``` ### Response #### Success Response (200) Returns a link object upon successful creation. #### Response Example ```json { "id": "clnk_abc123", "url": "https://dub.co", "track_conversion": true } ``` ``` -------------------------------- ### Verifying Installation Source: https://dub.co/docs/conversions/leads/introduction Tests to verify the correct installation of the @dub/analytics script. ```APIDOC ## Installation Verification ### Description Tests to verify the correct installation of the `@dub/analytics` script. ### Steps 1. Open the browser console and type `_dubAnalytics`. You should see the `_dubAnalytics` object. 2. Add the `?dub_id=test` query parameter to your website URL and check if the `dub_id` cookie is set. ### Troubleshooting * Ensure the analytics script is in the `
` section. * If using a CDN, purge cached content. ``` -------------------------------- ### Create Link with Conversion Tracking (JavaScript, Python, Go, Ruby) Source: https://dub.co/docs/conversions/leads/segment Demonstrates how to create a short link with conversion tracking enabled using the Dub.co SDK in JavaScript, Python, Go, and Ruby. These examples show the basic API calls for each language, requiring the respective SDK to be installed. ```javascript await dub.links.create({ url: "https://dub.co", trackConversion: true, }); ``` ```python link = d.links.create(url="https://dub.co", track_conversion=True) ``` ```go link, err := d.Links.Create(ctx, &dub.CreateLinkRequest{ URL: "https://dub.co", TrackConversion: true, }) ``` ```ruby s.links.create_many( ::OpenApiSDK::Operations::CreateLinkRequest.new( url: "https://dub.co", track_conversion: true, ) ) ``` -------------------------------- ### Python SDK Example Source: https://dub.co/docs/conversions/leads/appwrite Example of creating a link with conversion tracking enabled using the Python SDK. ```APIDOC ## Python SDK Example ### Description This code snippet shows how to create a new link with conversion tracking enabled using the Dub Python SDK. ### Method `d.links.create()` ### Endpoint N/A (Server-side SDK) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **url** (string) - Required - The destination URL for the link. * **track_conversion** (boolean) - Optional - Set to `True` to enable conversion tracking for this link. ### Request Example ```python link = d.links.create(url="https://dub.co", track_conversion=True) ``` ### Response #### Success Response (200) Returns a link object upon successful creation. #### Response Example ```json { "id": "clnk_abc123", "url": "https://dub.co", "track_conversion": true } ``` ``` -------------------------------- ### Install Dub Ruby SDK Source: https://dub.co/docs/sdks/ruby Installs the Dub Ruby SDK using the RubyGems package manager. Ensure you have Ruby and RubyGems installed on your system. ```bash gem install dub ``` -------------------------------- ### JavaScript Client-Side Installation Source: https://dub.co/docs/conversions/leads/introduction Install the @dub/analytics script to track conversion events on your website. ```APIDOC ## JavaScript ### Description Install the @dub/analytics script to track conversion events on your website. ### Method Not Applicable (Client-Side Script Installation) ### Endpoint Not Applicable (Client-Side Script Installation) ### Parameters Not Applicable ### Request Example ```javascript _dubAnalytics.init({ url: "https://dub.co", trackConversion: true, }); ``` ### Response Not Applicable ``` -------------------------------- ### Install Project Dependencies Source: https://dub.co/docs/local-development Installs all necessary project dependencies using the pnpm package manager. Ensure Node.js and pnpm are installed on your system. ```bash pnpm i ``` -------------------------------- ### JavaScript SDK Example Source: https://dub.co/docs/conversions/leads/appwrite Example of creating a link with conversion tracking enabled using the JavaScript SDK. ```APIDOC ## JavaScript SDK Example ### Description This code snippet demonstrates how to create a new link with conversion tracking enabled using the Dub JavaScript SDK. ### Method `d.links.create()` ### Endpoint N/A (Client-side SDK) ### Parameters #### Query Parameters None #### Request Body * **url** (string) - Required - The destination URL for the link. * **trackConversion** (boolean) - Optional - Set to `true` to enable conversion tracking for this link. ### Request Example ```javascript dub.init('YOUR_API_KEY', { trackConversion: true, }); ``` ### Response #### Success Response (200) Returns a link object upon successful creation. #### Response Example ```json { "id": "clnk_abc123", "url": "https://dub.co", "trackConversion": true } ``` ``` -------------------------------- ### Install @dub/better-auth Plugin Source: https://dub.co/docs/conversions/leads/better-auth Instructions for installing the @dub/better-auth plugin using various package managers. This plugin enhances authentication capabilities. ```npm npm install @dub/better-auth ``` ```yarn yarn add @dub/better-auth ``` ```pnpm pnpm add @dub/better-auth ``` ```bun bun add @dub/better-auth ``` -------------------------------- ### Set Up Environment Variables Source: https://dub.co/docs/local-development Copies the example environment file to `.env` within the `apps/web` directory. This file will be used to store sensitive configuration values. ```bash cp .env.example .env ``` -------------------------------- ### Client-Side Conversion Tracking Setup Source: https://dub.co/docs/conversions/sales/direct Steps to set up client-side conversion tracking, including allowlisting your domain and generating a publishable key. ```APIDOC ## Client-Side Conversion Tracking Setup To track conversions directly from your website, follow these steps: ### Step 1: Allowlist Your Site's Domain Navigate to your [workspace's Analytics settings page](https://app.dub.co/settings/analytics) and add your site's domain to the **Allowed Hostnames** list. This ensures that only authorized domains can track conversions using your publishable key. **Examples:** * `example.com`: Tracks traffic only from `example.com`. * `*.example.com`: Tracks traffic from all subdomains of `example.com`, but not from `example.com` itself. **Tip:** For local testing, temporarily add `localhost` to the **Allowed Hostnames** list. ### Step 2: Generate Your Publishable Key Before tracking client-side conversions, generate a [publishable key](/api-reference/publishable-keys) from your Dub workspace. Go to your [workspace's Analytics settings page](https://app.dub.co/settings/analytics) and find the **Publishable Key** section to generate a new key. ``` -------------------------------- ### Install @dub/analytics Script Source: https://dub.co/docs/conversions/leads/hubspot Instructions for installing the @dub/analytics script on a website to track conversion events. This can be done manually or through various platform-specific guides. ```javascript // Example for manual installation (refer to specific guides for React, Framer, Shopify, etc.) // ``` -------------------------------- ### Client-Side Conversion Tracking Setup Source: https://dub.co/docs/sdks/client-side/features/conversion-tracking Instructions for setting up client-side conversion tracking, including allowlisting domains and generating a publishable key. ```APIDOC ## Client-Side Conversion Tracking Setup ### Description This section outlines the steps required to enable client-side conversion tracking for your website using Dub. ### Steps #### 1. Allowlist Your Site's Domain To ensure only authorized domains can track conversions, you must allowlist your site's domain in your Dub workspace settings. **Navigation:** Go to your [workspace's Analytics settings page](https://app.dub.co/settings/analytics). **Action:** Add your site's domain to the **Allowed Hostnames** list. **Examples:** * `example.com`: Tracks traffic *only* from `example.com`. * `*.example.com`: Tracks traffic from *all subdomains* of `example.com`, but *not* from `example.com` itself. **Local Testing:** Temporarily add `localhost` to the **Allowed Hostnames** list for local development testing. #### 2. Generate Your Publishable Key Before client-side tracking can function, you need a publishable key. **Navigation:** Go to your [workspace's Analytics settings page](https://app.dub.co/settings/analytics). **Action:** Generate a new publishable key under the **Publishable Key** section. ### Parameters N/A (Configuration steps) ### Request Example N/A ### Response N/A #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Initialize Dub SDK and Track First Launch Source: https://dub.co/docs/sdks/client-side-mobile/installation-guides/swift Initializes the Dub SDK with your publishable key and domain. It also tracks the first launch of the application to gather analytics. This function should be called early in your application's lifecycle. ```swift Dub.setup(publishableKey: dubPublishableKey, domain: dubDomain) // Track first launch if isFirstLaunch { trackOpen() isFirstLaunch = false } // Override point for customization after application launch. return true ``` -------------------------------- ### Start Ngrok Tunnel Source: https://dub.co/docs/local-development Starts an Ngrok tunnel to expose your local server on port 8888 to the internet. This is essential for Qstash to connect to your local environment. Ensure Ngrok is installed and configured before running this command. ```bash ngrok http 8888 ``` -------------------------------- ### Start Development Server with pnpm Source: https://dub.co/docs/local-development Starts the development server for the application using the pnpm package manager. This command builds and launches the application, making it accessible via specified local URLs. ```bash pnpm dev ``` -------------------------------- ### Configure @dub/better-auth Plugin Source: https://dub.co/docs/conversions/leads/better-auth Example configuration for integrating the @dub/better-auth plugin into a better-auth setup. It requires initializing the Dub client and passing it to the plugin. ```typescript import { dubAnalytics } from "@dub/better-auth"; import { betterAuth } from "better-auth"; import { Dub } from "dub"; const dub = new Dub(); export const auth = betterAuth({ plugins: [ dubAnalytics({ dubClient: dub, }), ], }); ``` -------------------------------- ### Configure Dub Analytics with Custom Domains Source: https://dub.co/docs/sdks/client-side/installation-guides/manual This example shows how to configure custom domains for Dub analytics tracking using the `data-domains` attribute. It allows specifying domains for referral programs, site visits, and outbound cross-domain tracking. ```html ``` -------------------------------- ### Check Dub CLI Version Source: https://dub.co/docs/sdks/cli Verify the currently installed version of the Dub CLI on your system. This command is useful for troubleshooting and ensuring compatibility with other Dub services. The output will display the version number, for example, '0.0.12'. ```bash dub --version # => 0.0.12 ``` -------------------------------- ### Test Deep Links on Android Emulator using ADB Source: https://dub.co/docs/concepts/deep-links/quickstart This bash command demonstrates how to test a deep link on an Android emulator using the Android Debug Bridge (adb). It starts an activity that handles the specified deep link URI, allowing verification of deep link functionality before production deployment. ```bash adb shell am start -W -a android.intent.action.VIEW -d "https://yourdomain.link/your-short-link" com.yourpackage.name ``` -------------------------------- ### Clone Dub Repository Source: https://dub.co/docs/local-development Clones the Dub GitHub repository to your local machine. This is the first step in setting up the project. ```bash git clone https://github.com/dubinc/dub.git ``` -------------------------------- ### Install Dub Analytics Script (React) Source: https://dub.co/docs/conversions/sales/segment Instructions for installing the `@dub/analytics` script in a React application to track conversion events. This is a client-side installation method. ```javascript import "@dub/analytics"; ``` -------------------------------- ### Install @dub/analytics SDK (Manual) Source: https://dub.co/docs/conversions/quickstart Instructions for manually installing the `@dub/analytics` client-side SDK. This script is essential for capturing the `dub_id` query parameter and attributing subsequent conversions to the original link. It should be added to the `` section of your web page. ```html ``` -------------------------------- ### Install Dub TypeScript SDK with yarn Source: https://dub.co/docs/sdks/quickstart/remix Installs the Dub TypeScript SDK and its peer dependency Zod using yarn. Ensure Zod is installed if you are using yarn. ```bash yarn add dub zod ``` -------------------------------- ### Go SDK - Create Link Source: https://dub.co/docs/conversions/leads/introduction Example of creating a link with conversion tracking enabled using the Go SDK. ```APIDOC ## POST /links (Go SDK) ### Description Creates a new link with conversion tracking enabled using the Go SDK. ### Method POST ### Endpoint Not Applicable (SDK Method) ### Parameters Not Applicable ### Request Example ```go link, err := d.Links.Create(ctx, &dub.CreateLinkRequest{ URL: "https://dub.co", TrackConversion: true, }) ``` ### Response Success Response (200) - **link** (object) - The created link object. - **err** (error) - An error if the creation failed. ``` -------------------------------- ### Create Link with Conversion Tracking (Python, Go, Ruby, JavaScript) Source: https://dub.co/docs/conversions/leads/supabase Code examples for creating a short link that tracks conversion events using the Dub.co SDK. Supports Python, Go, Ruby, and JavaScript. Dependencies include the respective Dub.co SDKs for each language. Inputs are the URL and a boolean for conversion tracking. Outputs are link objects. ```javascript const dubAnalytics = require('@dub/analytics') dubAnalytics.client.create({ url: "https://dub.co", trackConversion: true, }); ``` ```python link = d.links.create(url="https://dub.co", track_conversion=True) ``` ```go link, err := d.Links.Create(ctx, &dub.CreateLinkRequest{ URL: "https://dub.co", TrackConversion: true, }) ``` ```ruby s.links.create_many( ::OpenApiSDK::Operations::CreateLinkRequest.new( url: "https://dub.co", track_conversion: true, ) ) ``` -------------------------------- ### Install Dub CLI using npm, yarn, or pnpm Source: https://dub.co/docs/sdks/cli Install the Dub CLI globally on your system using your preferred package manager. This command ensures you have the latest version of the CLI available for use in your terminal. To update an existing installation, simply re-run the installation command. ```bash npm i -g dub-cli@latest ``` ```bash yarn global add dub-cli@latest ``` ```bash pnpm i -g dub-cli@latest ``` -------------------------------- ### Initialize Dub Go SDK Source: https://dub.co/docs/sdks/quickstart/go Initializes the Dub Go SDK by creating a new instance of the Dub struct. It configures the SDK with an API key retrieved from environment variables. ```go package main import ( "log" "os" "context" dub "github.com/dubinc/dub-go" ) d := dub.New( dub.WithSecurity(os.Getenv("DUB_API_KEY")), ) ``` -------------------------------- ### Initialize Dub iOS SDK (SwiftUI) Source: https://dub.co/docs/concepts/deep-links/attribution Sets up the Dub SDK for iOS applications using SwiftUI. It requires a publishable key and domain, and exposes the Dub instance as an environment value. ```swift import SwiftUI import Dub @main struct DubApp: App { // Step 1: Obtain your Dub domain and publishable key private let dubPublishableKey = "