UIEventAttribution
An object that contains event attribution information for Web AdAttributionKit.
Declaration
@MainActor class UIEventAttributionOverview
Apps use event attribution objects to send data to the browser when opening an external website that supports Web AdAttributionKit (formerly known as Private Click Measurement, or PCM). For more information on the proposed PCM web standard, see Introducing Private Click Measurement and Private Click Measurement Draft Community Group Report.
You can’t subclass UIEventAttribution.
Define an endpoint
In order to use Web AdAttributionKit, your app defines an Info.plist key called NSAdvertisingAttributionReportEndpoint that contains the URL to which the browser sends event attribution data. When an externally linked website reports that a conversion has occurred, the browser forwards your app’s event attribution data to the endpoint specified in the Info.plist. If your app’s Info.plist doesn’t contain this key, the browser won’t be able to forward the Web AdAttributionKit data when a conversion occurs.
Send event attribution data to the browser only when your app opens an external link as a result of a user tapping a control that sits below a UIEventAttributionView in the app’s view hierarchy. The event attribution view verifies that the user tapped a control. If that control doesn’t sit below an event attribution view, the system won’t send the Web AdAttributionKit data to the browser when opening the external link.
Create an event attribution data object
Here’s how you create a UIEventAttribution object:
Send event attribution data to the browser
Once you create a UIEventAttribution object, send it to the browser when your app opens a URL as the result of a user tap. If the external website reports a conversion within 7 days, the browser forwards the data from the UIEventAttribution object to the specified remote server sometime between 24 and 48 hours after the conversion.
There are two different ways to send event attribution data when your app opens an external link, depending on whether your app uses UIScene or UIApplication for life cycle management. For more information on application life cycle management, see Managing your app’s life cycle.
If your app uses UIScene-based life cycle management, create a UIScene.OpenExternalURLOptions object, assign the event attribution object you created to its eventAttribution property, and call open(_:options:completionHandler:):
If your app uses UIApplication-based life cycle management, create a dictionary that contains the eventAttribution key with the UIEventAttribution object you created as its value, and call open(_:options:completionHandler:), passing the dictionary using the options parameter.
Send event attribution data to SFSafariViewController
If your app displays a web page in SFSafariViewController after a person taps an ad, add a UIEventAttributionView subview to the ad view or control in order to measure taps. When a person taps the ad, follow these steps:
Create an SFSafariViewController.Configuration object.
Assign the UIEventAttribution object you created to the eventAttribution property of the SFSafariViewController.Configuration object.
Initialize an SFSafariViewController instance with the configuration object, and present it. SFSafariViewController validates that a tap on a UIEventAttributionView initiated the navigation to the webpage. If not, it discards the attribution data.