Skip to main content

Development Guide

This guide helps developers integrate Inhouse into their applications, whether you’re building web apps, mobile applications, or backend services.

Getting Started

Choose Your Integration Method

Inhouse offers multiple ways to integrate with your applications:

SDKs & Libraries

Use our official SDKs for easy integration

REST API

Build custom integrations with our REST API

Webhooks

Receive real-time updates via webhooks

Deep Linking

Implement seamless app-to-app navigation

Platform Architecture

Core Components

Inhouse is built around these key components:
  • Links Management: Create, track, and optimize marketing links
  • Apps Tracking: Monitor mobile application performance and user behavior
  • Extensions Tracking: Track browser extension usage and engagement
  • Customer Management: Manage customer relationships and sales data
  • Analytics Engine: Comprehensive reporting and insights

Data Flow

Integration Patterns

Web Applications

For web applications, use our Web SDK:
import { Inhouse } from '@inhouse/web';

// Initialize the SDK
Inhouse.init({
  apiKey: 'YOUR_API_KEY',
  projectId: 'YOUR_PROJECT_ID'
});

// Track user interactions
Inhouse.track('button_click', {
  button: 'signup',
  page: 'homepage'
});
Key Features:
  • Automatic page view tracking
  • User interaction monitoring
  • Performance metrics
  • Deep linking support

Mobile Applications

For mobile apps, choose the appropriate SDK:
npm install @inhouse/react-native
Perfect for cross-platform mobile development with React Native.
dependencies:
  inhouse_flutter: ^1.0.0
Ideal for Flutter-based cross-platform applications.
import InhouseSDK
Inhouse.configure(apiKey: "YOUR_API_KEY", projectId: "YOUR_PROJECT_ID")
For native iOS applications using Swift or Objective-C.
implementation 'com.inhouse:sdk:1.0.0'
For native Android applications using Kotlin or Java.

Backend Services

For backend integrations, use our REST API:
curl -X POST https://api.tryinhouse.co/v1/links \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "destination_url": "https://example.com/landing",
    "custom_key": "campaign-123",
    "campaign": "Summer Sale 2024"
  }'

Deep Linking Implementation

Configure universal links for seamless web-to-app navigation:
// Add associated domains capability
// applinks:yourdomain.com

// Handle universal links
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
        if let url = userActivity.webpageURL {
            handleUniversalLink(url)
            return true
        }
    }
    return false
}
Configure app links for Android:
<activity android:name=".MainActivity">
  <intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    
    <data android:scheme="https"
           android:host="yourdomain.com"
           android:pathPrefix="/app" />
  </intent-filter>
</activity>

Web Deep Linking

Implement deep linking in web applications:
// Check if mobile app is available
Inhouse.checkAppAvailability().then(available => {
  if (available) {
    // Try to open app with deep link
    Inhouse.openApp('product/123');
  } else {
    // Fallback to web or app store
    window.location.href = 'https://apps.apple.com/app/your-app';
  }
});

Event Tracking Strategy

Core Events

Track these essential events across your application:
// Page/Screen Views
Inhouse.track('screen_view', {
  screen: 'ProductDetail',
  productId: 'prod_123'
});

// User Interactions
Inhouse.track('button_click', {
  button: 'add_to_cart',
  productId: 'prod_123'
});

// Business Events
Inhouse.track('purchase', {
  orderId: 'order_456',
  total: 99.99,
  currency: 'USD'
});

Custom Events

Create custom events for your specific business needs:
// E-commerce specific
Inhouse.track('product_viewed', {
  productId: 'prod_123',
  category: 'electronics',
  price: 99.99
});

// User engagement
Inhouse.track('feature_used', {
  feature: 'advanced_search',
  usage: 'daily'
});

Performance Monitoring

Core Web Vitals

Track performance metrics automatically:
Inhouse.init({
  performance: {
    trackCoreWebVitals: true,
    trackPageLoad: true,
    trackResourceTiming: true
  }
});

Custom Performance Tracking

Monitor application-specific performance:
// API response times
const startTime = performance.now();
fetch('/api/products')
  .then(response => response.json())
  .then(data => {
    const duration = performance.now() - startTime;
    
    Inhouse.track('api_performance', {
      endpoint: '/api/products',
      duration: duration,
      status: 'success'
    });
  });

User Identification

Setting User Properties

Identify users and track their behavior:
// Set user ID
Inhouse.identify('user_123');

// Set user properties
Inhouse.setUserProperties({
  email: '[email protected]',
  plan: 'premium',
  signupDate: '2024-01-15'
});

User Segmentation

Group users for targeted analytics:
// Set user segments
Inhouse.setUserProperty('segment', 'high-value');
Inhouse.setUserProperty('cohort', '2024-Q1');

// Track segment-specific events
if (Inhouse.getUserProperty('segment') === 'high-value') {
  Inhouse.track('premium_feature_used', {
    feature: 'advanced_analytics'
  });
}

Privacy and Compliance

GDPR Compliance

Implement proper consent management:
Inhouse.init({
  privacy: {
    gdprCompliant: true,
    requireConsent: true,
    dataRetentionDays: 365
  }
});

// Set user consent
Inhouse.setConsent({
  analytics: true,
  marketing: false,
  necessary: true
});

// Conditional tracking
if (Inhouse.hasConsent('analytics')) {
  Inhouse.track('user_action', { action: 'button_click' });
}

Data Anonymization

// Anonymize user data
Inhouse.anonymizeUser();

// Set data retention
Inhouse.setDataRetention({
  events: 90, // days
  userProperties: 365, // days
  sessions: 30 // days
});

Webhook Integration

Setting Up Webhooks

Receive real-time updates from Inhouse:
curl -X POST https://api.tryinhouse.co/v1/webhooks \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-app.com/webhooks/inhouse",
    "events": ["link.created", "link.clicked"],
    "secret": "your-webhook-secret"
  }'

Webhook Handling

Process incoming webhook data:
// Express.js webhook handler
app.post('/webhooks/inhouse', (req, res) => {
  const { event, data, timestamp } = req.body;
  
  // Verify webhook signature
  if (!verifyWebhookSignature(req, webhookSecret)) {
    return res.status(401).send('Unauthorized');
  }
  
  // Process the event
  switch (event) {
    case 'link.clicked':
      handleLinkClick(data);
      break;
    case 'link.created':
      handleLinkCreated(data);
      break;
  }
  
  res.status(200).send('OK');
});

Testing and Debugging

Development Environment

Use the sandbox environment for testing:
Inhouse.init({
  apiKey: 'YOUR_SANDBOX_API_KEY',
  projectId: 'YOUR_SANDBOX_PROJECT_ID',
  environment: 'development'
});

Debug Mode

Enable debug logging during development:
Inhouse.init({
  // ... other config
  debug: true
});

// Debug methods
Inhouse.debug('User clicked button');
Inhouse.debug('Event tracked:', { event: 'button_click' });

Testing Tools

// Mock mode for testing
Inhouse.init({
  // ... other config
  mock: true
});

// Test event tracking
Inhouse.track('test_event', { test: true });

// Verify events
const events = Inhouse.getMockEvents();
console.log('Mock events:', events);

Best Practices

Event Design

  1. Consistent Naming: Use snake_case for event names
  2. Descriptive Names: Make event names self-explanatory
  3. Logical Grouping: Use prefixes for related events
  4. Documentation: Document your event schema

Performance Optimization

  1. Event Batching: Use batching for high-frequency events
  2. Debouncing: Debounce rapid-fire events
  3. Lazy Loading: Load SDK only when needed
  4. Minimal Payload: Keep event data focused

Privacy and Security

  1. User Consent: Always respect user privacy preferences
  2. Data Minimization: Only collect necessary data
  3. Secure Transmission: Use HTTPS for all communications
  4. Regular Audits: Review data collection practices

Troubleshooting

Common Issues

  • Check API key and project ID
  • Verify network connectivity
  • Check browser console for errors
  • Verify SDK initialization
  • Verify event tracking calls
  • Check property values
  • Review event naming
  • Test in debug mode
  • Enable event batching
  • Reduce event frequency
  • Check for memory leaks
  • Monitor network requests

Debug Commands

// Check SDK status
console.log('SDK Status:', Inhouse.getStatus());

// View configuration
console.log('Configuration:', Inhouse.getConfig());

// Check user properties
console.log('User Properties:', Inhouse.getUserProperties());

// View session info
console.log('Session Info:', Inhouse.getSessionInfo());

Integration Examples

React Application

import React, { useEffect } from 'react';
import { Inhouse } from '@inhouse/web';

function ProductPage({ productId }) {
  useEffect(() => {
    // Track page view
    Inhouse.track('screen_view', {
      screen: 'ProductDetail',
      productId: productId
    });
  }, [productId]);

  const handleAddToCart = () => {
    Inhouse.track('button_click', {
      button: 'add_to_cart',
      productId: productId
    });
    // Add to cart logic
  };

  return (
    <div>
      <h1>Product Details</h1>
      <button onClick={handleAddToCart}>Add to Cart</button>
    </div>
  );
}

Vue.js Application

<template>
  <div>
    <h1>Product Details</h1>
    <button @click="addToCart">Add to Cart</button>
  </div>
</template>

<script>
import { Inhouse } from '@inhouse/web';

export default {
  name: 'ProductPage',
  props: ['productId'],
  
  mounted() {
    Inhouse.track('screen_view', {
      screen: 'ProductDetail',
      productId: this.productId
    });
  },
  
  methods: {
    addToCart() {
      Inhouse.track('button_click', {
        button: 'add_to_cart',
        productId: this.productId
      });
      // Add to cart logic
    }
  }
};
</script>

Node.js Backend

const { InhouseClient } = require('@inhouse/node');

const client = new InhouseClient('YOUR_API_TOKEN');

// Create a link
async function createLink(destinationUrl, customKey, campaign) {
  try {
    const link = await client.links.create({
      destination_url: destinationUrl,
      custom_key: customKey,
      campaign: campaign
    });
    
    console.log('Link created:', link.short_url);
    return link;
    
  } catch (error) {
    console.error('Error creating link:', error);
    throw error;
  }
}

// Track an event
async function trackEvent(eventName, properties) {
  try {
    await client.track(eventName, properties);
    console.log('Event tracked:', eventName);
    
  } catch (error) {
    console.error('Error tracking event:', error);
    throw error;
  }
}

Next Steps

SDK Documentation

Get started with our official SDKs.

API Reference

Explore our comprehensive REST API.

Deep Linking

Set up seamless app navigation.

Analytics

Understand your data and insights.
Need help with development? Check our API documentation or contact [email protected].