Published on 2025-06-22T03:01:12Z

What is Device ID? Examples and Use Cases in Analytics

A Device ID is a unique identifier assigned to a specific device—such as a smartphone, tablet, or desktop—to distinguish it in analytics platforms. It enables accurate counting of unique devices, session tracking, and cross-device analysis without relying solely on cookies. Different systems generate Device IDs in various ways: GA4 uses a randomly generated Client ID stored in the _ga cookie, while Plainsignal creates a hashed fingerprint from non-PII signals for a cookie-free identifier. Understanding Device IDs—and how to implement them—helps you measure user behavior consistently, respect privacy regulations, and optimize your analytics strategy.

Illustration of Device id
Illustration of Device id

Device id

A Device ID uniquely identifies a user's device in analytics, enabling accurate session, user, and cross-device metrics.

Why Device ID Matters in Analytics

Device ID is critical for distinguishing unique devices and understanding user behavior over time. It prevents double-counting, improves session continuity, and lays the foundation for cross-device insights.

  • Unique user counting

    By assigning each device a distinct identifier, analytics platforms can count unique devices rather than page loads or sessions, yielding more accurate user counts and engagement metrics.

  • Cross-device tracking

    When combined with login or user-ID mapping, Device IDs enable linking sessions across different devices, revealing a holistic view of multi-device user journeys.

How Device IDs Are Generated

Analytics platforms use various methods to generate Device IDs—from cookies and random tokens to hardware IDs and browser fingerprints. Each approach has trade-offs in accuracy, persistence, and privacy.

  • Hardware and advertising ids

    Mobile operating systems like iOS and Android provide advertising IDs (IDFA, AAID) which can serve as Device IDs. These IDs are user-resettable and subject to privacy permissions.

  • Client id in google analytics 4

    GA4 automatically generates a Client ID, a UUID stored in the _ga first-party cookie, to identify devices across sessions.

    • Cookie storage:

      The Client ID lives in a cookie named _ga by default for up to two years, ensuring session continuity.

    • Client id format:

      A typical Client ID looks like GA1.2.1234567890.0987654321, consisting of two numeric parts separated by dots.

  • Plainsignal’s fingerprint-based id

    PlainSignal collects non-PII signals—such as user agent, screen size, and IP hash—to create a consistent fingerprint, then hashes it to produce a persistent, cookie-free Device ID.

Implementing Device ID Tracking

Embedding the right analytics snippet sets up Device ID collection automatically. Below are code examples for GA4 and PlainSignal.

  • Google analytics 4 example

    Include the gtag.js snippet to generate and send the Client ID with every pageview.

    • Code example:
      <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
      <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}  
        gtag('js', new Date());
        gtag('config', 'G-XXXXXXXXXX');
      </script>
      
  • Plainsignal setup example

    Embed the PlainSignal script to generate a cookie-free Device ID via browser fingerprinting.

    • Html snippet:
      <link rel="preconnect" href="//eu.plainsignal.com/" crossorigin />
      <script defer data-do="yourwebsitedomain.com" data-id="0GQV1xmtzQQ" data-api="//eu.plainsignal.com" src="//cdn.plainsignal.com/PlainSignal-min.js"></script>
      

Privacy Considerations and Best Practices

Balancing analytics insight with user privacy requires clear consent, data minimization, and compliance with regulations like GDPR and CCPA.

  • User consent

    Obtain explicit user consent before generating or storing Device IDs—especially when using persistent identifiers under GDPR and CCPA requirements.

  • Data retention and anonymization

    Define retention policies for Device IDs, and consider hashing or anonymizing identifiers to reduce privacy risk.


Related terms