Unity SDK - Supporting SKAdNetwork & ATT

Supporting SKAdNetwork

SKAdNetwork is Apple's privacy-focused attribution framework for iOS app install campaigns. Starting with Unity SDK version 4.0.17, SKAdNetwork is enabled by default in Managed Mode, where Singular automatically updates conversion values based on your configured conversion model in the dashboard.

No Additional Configuration Required: If you're using the latest Unity SDK, SKAdNetwork works out of the box. No code changes or additional settings are needed for basic functionality.

Understanding SKAN Modes

Managed Mode (Default)

In Managed Mode, Singular automatically handles conversion value updates based on the conversion model you configure in your dashboard. This is the recommended approach for most apps as it requires minimal code and provides optimal conversion tracking.

  • Automatic updates: Singular manages all conversion value updates based on user events and your configured model.
  • Dashboard configuration: Design your conversion model in the Singular dashboard without code changes.
  • Optimization: Benefit from Singular's expertise in maximizing conversion value updates within Apple's constraints.

Manual Mode (Advanced)

Manual Mode gives you complete control over conversion value updates, allowing you to implement custom logic for determining when and how to update SKAN conversion values. Use this mode only if you have specific requirements that Managed Mode cannot fulfill.

Advanced Feature: Manual Mode requires careful implementation and understanding of Apple's SKAdNetwork constraints, including conversion value update windows and limitations. Most apps should use Managed Mode.

Legacy SDK Versions

If you're using a Unity SDK version older than 4.0.17, you need to manually enable SKAdNetwork support using one of the following methods.

Enabling SKAdNetwork in Older SDK Versions
#

Method 1: Unity Inspector Configuration

  1. Select the SingularSDKObject in your Unity scene hierarchy.
  2. In the Inspector pane, locate the SKANEnabled property.
  3. Set SKANEnabled to True.
  4. Save your scene and rebuild your project.

Method 2: Programmatic Registration

Call the registration method in your app initialization code before any events are tracked.

C#
using UnityEngine;
using Singular;

public class AppInitializer : MonoBehaviour
{
    void Awake()
    {
        // Register for SKAdNetwork attribution
        SingularSDK.SkanRegisterAppForAdNetworkAttribution();
    }
}

Recommendation: Upgrade to the latest Unity SDK version to benefit from automatic SKAdNetwork enablement and the latest features and bug fixes.

Configuring Manual Mode

To implement custom conversion value logic, enable Manual Mode and use the provided SDK methods to update and monitor conversion values throughout your app's lifecycle.

Using SKAdNetwork in Manual Mode (Advanced)
#

Enable Manual Mode

  1. Select the SingularSDKObject in your Unity scene hierarchy.
  2. In the Inspector pane, locate the manualSKANConversionManagement property.
  3. Set manualSKANConversionManagement to True.

Update Conversion Value

Use this method to manually update the SKAdNetwork conversion value based on your custom logic. The conversion value must be an integer between 0 and 63.

Important: This method only works when manualSKANConversionManagement is set to True. If Managed Mode is active, manual updates will be ignored.

Signature

C#
public static bool SkanUpdateConversionValue(int value)

Usage Example

C#
using UnityEngine;
using Singular;

public class ConversionTracker : MonoBehaviour
{
    void OnUserSignUp()
    {
        // Track the sign-up event
        SingularSDK.Event("SignUp");

        // Update SKAN conversion value to 7
        bool success = SingularSDK.SkanUpdateConversionValue(7);

        if (success)
        {
            Debug.Log("Conversion value updated successfully");
        }
        else
        {
            Debug.LogWarning("Failed to update conversion value");
        }
    }

    void OnPurchaseComplete(float purchaseAmount)
    {
        // Track revenue event
        SingularSDK.Revenue("USD", purchaseAmount);

        // Update conversion value based on purchase tier
        int conversionValue = CalculateConversionValue(purchaseAmount);
        SingularSDK.SkanUpdateConversionValue(conversionValue);
    }

    int CalculateConversionValue(float amount)
    {
        // Your custom logic to determine conversion value
        if (amount >= 100) return 63;      // High value
        if (amount >= 50) return 40;       // Medium value
        if (amount >= 10) return 20;       // Low value
        return 10;                          // Minimal value
    }
}

Get Current Conversion Value

Retrieve the current conversion value tracked by the Singular SDK. This is useful for implementing conditional logic based on the current state.

Signature

C#
public static int? SkanGetConversionValue()

Usage Example

C#
using UnityEngine;
using Singular;

public class ConversionMonitor : MonoBehaviour
{
    void CheckConversionValue()
    {
        int? currentValue = SingularSDK.SkanGetConversionValue();

        if (currentValue.HasValue)
        {
            Debug.Log($"Current conversion value: {currentValue.Value}");

            // Only update if current value is below threshold
            if (currentValue.Value < 30)
            {
                SingularSDK.SkanUpdateConversionValue(30);
            }
        }
        else
        {
            Debug.LogWarning("Conversion value not available");
        }
    }
}

Monitor Conversion Value Updates

Set up a handler to receive real-time notifications whenever the conversion value changes. This enables you to react to conversion value updates and log analytics or trigger other app behaviors.

Signature

C#
public static void SetConversionValueUpdatedHandler(SingularConversionValueUpdatedHandler handler)

Usage Example

C#
using UnityEngine;
using Singular;

public class ConversionValueMonitor : MonoBehaviour, SingularConversionValueUpdatedHandler
{
    void Awake()
    {
        // Register this class as the conversion value update handler
        SingularSDK.SetConversionValueUpdatedHandler(this);
    }

    // This method is called whenever the conversion value is updated
    public void OnConversionValueUpdated(int newValue)
    {
        Debug.Log($"Conversion value updated to: {newValue}");

        // Log the update to your analytics
        LogConversionValueUpdate(newValue);

        // Trigger any app-specific behavior
        if (newValue >= 50)
        {
            UnlockPremiumFeature();
        }
    }

    void LogConversionValueUpdate(int value)
    {
        // Your analytics logging logic
        Debug.Log($"Analytics: SKAN CV = {value}");
    }

    void UnlockPremiumFeature()
    {
        // Your custom logic
        Debug.Log("Premium feature unlocked based on high conversion value");
    }
}

Best Practice: Use the conversion value handler to maintain a synchronized view of the current conversion state across your app. This is especially useful for debugging and ensuring your custom logic works correctly.


Supporting App Tracking Transparency (ATT)

App Tracking Transparency (ATT) is Apple's privacy framework requiring user consent before accessing the device's IDFA (Identifier for Advertisers) and sharing user data. Implementing ATT correctly is critical for iOS attribution and maximizing the accuracy of your user acquisition campaigns.

Why ATT Matters for Attribution

Starting with iOS 14.5, apps must request user permission through the ATT framework before accessing the IDFA. While attribution is still possible without the IDFA using fingerprinting and probabilistic methods, having the IDFA significantly improves attribution accuracy and provides deterministic matching.

  • Deterministic attribution: The IDFA enables precise, device-level attribution that connects ad impressions directly to installs.
  • Ad network optimization: Ad networks can better optimize campaigns and provide more accurate reporting with IDFA access.
  • User-level insights: Access to IDFA allows for more granular user behavior analysis and cohort tracking.

Recommendation: Singular strongly recommends implementing the ATT prompt and requesting user consent. Explain the benefits to users (personalized ads, better app experience) to maximize opt-in rates.

SDK Initialization Timing

The timing of SDK initialization relative to the ATT prompt is critical. If the SDK initializes and sends the first session before the user responds to the ATT prompt, the IDFA won't be captured, resulting in less accurate attribution.

Why Delay Initialization?

By default, the Singular SDK sends a session immediately upon initialization. When this session comes from a new device, it triggers Singular's attribution process using only the data available at that moment. If the user hasn't yet responded to the ATT prompt, the IDFA will be unavailable, and the attribution will be based on less accurate methods.

Critical: Always request ATT consent and retrieve the IDFA before the Singular SDK sends its first session. Failing to do so will permanently lose the IDFA for that device's attribution data.

Configure SDK Wait Timeout

Configure the SDK to wait for the user's ATT response before initializing by setting the waitForTrackingAuthorizationWithTimeoutInterval property. This delay gives the user time to respond to the ATT prompt while preventing indefinite delays if the prompt is not shown.

Configuration Steps

  1. Select the SingularSDKObject in your Unity scene hierarchy.
  2. In the Inspector pane, locate the waitForTrackingAuthorizationWithTimeoutInterval property.
  3. Set the value based on your ATT implementation:
    • Showing ATT prompt: Set to 300 (5 minutes)
    • Not showing ATT prompt: Leave at 0 (no wait)

Recommended Value: If your app displays the ATT prompt, set the timeout to 300 seconds (5 minutes). This provides sufficient time for the user to see and respond to the prompt without creating a poor user experience if the prompt is delayed or not shown.

Implementation Example

Here's how to implement ATT in your Unity app with proper SDK initialization timing.

C#
using UnityEngine;
using Singular;

#if UNITY_IOS
using Unity.Advertisement.IosSupport;
#endif

public class ATTManager : MonoBehaviour
{
    void Start()
    {
#if UNITY_IOS
        // Check ATT status on iOS
        RequestTrackingAuthorization();
#else
        // Initialize SDK immediately on non-iOS platforms
        InitializeSingularSDK();
#endif
    }

#if UNITY_IOS
    void RequestTrackingAuthorization()
    {
        // Check current authorization status
        var status = ATTrackingStatusBinding.GetAuthorizationTrackingStatus();

        if (status == ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED)
        {
            // Request authorization if not yet determined
            ATTrackingStatusBinding.RequestAuthorizationTracking(OnATTResponse);
        }
        else
        {
            // Status already determined, initialize SDK
            InitializeSingularSDK();
        }
    }

    void OnATTResponse(int status)
    {
        // Log the user's response
        switch (status)
        {
            case (int)ATTrackingStatusBinding.AuthorizationTrackingStatus.AUTHORIZED:
                Debug.Log("User authorized tracking - IDFA will be available");
                break;
            case (int)ATTrackingStatusBinding.AuthorizationTrackingStatus.DENIED:
                Debug.Log("User denied tracking - IDFA not available");
                break;
            case (int)ATTrackingStatusBinding.AuthorizationTrackingStatus.RESTRICTED:
                Debug.Log("Tracking restricted by device settings");
                break;
            default:
                Debug.Log("ATT status unknown");
                break;
        }

        // Initialize SDK after receiving response
        InitializeSingularSDK();
    }
#endif

    void InitializeSingularSDK()
    {
        // SDK is initialized with waitForTrackingAuthorizationWithTimeoutInterval
        // configured in the Inspector, so it will wait for ATT if needed
        // If Initialize On Awake is disabled, manually initialize here
        // SingularSDK.InitializeSingularSDK();

        Debug.Log("Singular SDK initialized");
    }
}

ATT Best Practices

  • Pre-prompt messaging: Show users a pre-ATT screen explaining why you need tracking permission and how it benefits them (better ads, improved experience). This can significantly increase opt-in rates.
  • Timing matters: Show the ATT prompt at a natural moment in your app flow, not immediately on first launch. Let users experience your app first.
  • Custom messaging: Customize your ATT prompt message in your Info.plist file using the NSUserTrackingUsageDescription key to clearly explain your tracking purpose.
  • Test thoroughly: Test both authorized and denied scenarios to ensure your app functions correctly regardless of the user's choice.
  • Respect user choice: Never repeatedly prompt users who have denied tracking or show aggressive messaging that pressures them to opt in.

App Store Review: Apps that don't properly implement ATT or attempt to circumvent the framework may be rejected during App Store review. Ensure your implementation follows Apple's guidelines and respects user privacy choices.

Additional Resources