adjust-icon

Get attribution information

When a user interacts with an Adjust link, their attribution information may update. This can happen, for example, if they click on a deep link.

Attribution table values

The attribution table contains details about the current attribution status of the device. Any values that aren’t populated for the user are returned as nil.

ValuesData typeDescription
trackerTokenstringThe token of the link to which the device is currently attributed
trackerNamestringThe name of the link to which the device is currently attributed
networkstringThe name of the network to which the device is currently attributed
campaignstringThe name of the campaign to which the device is currently attributed
adgroupstringThe name of the adgroup to which the device is currently attributed
creativestringThe name of the creative to which the device is currently attributed
clickLabelstringThe click label that the install is tagged with
costTypestringThe campaign pricing model (for example cpi)
costAmountnumberThe cost of the install.
costCurrencystringThe 3 character ISO 4217 code of the currency associated with the cost.
fbInstallReferrerstringThe Facebook install referrer.
jsonResponsestringThe attribution response that the backend sends to the SDK.

Trigger a function when attribution changes

The SDK can listen for attribution changes and call a function whenever it detects an update. To configure your callback function, use the setAttributionCallback method.

local adjust = require "plugin.adjust"
local json = require "json"
-- attribution callback needs to be set before calling initSdk method
adjust.setAttributionCallback(function(event)
local json_attribution = json.decode(event.message)
print("Attribution changed!")
print("Tracker token: " .. (json_attribution.trackerToken or "N/A"))
print("Tracker name: " .. (json_attribution.trackerName or "N/A"))
print("Campaign: " .. (json_attribution.campaign or "N/A"))
print("Network: " .. (json_attribution.network or "N/A"))
print("Creative: " .. (json_attribution.creative or "N/A"))
print("Adgroup: " .. (json_attribution.adgroup or "N/A"))
print("Cost type: " .. (json_attribution.costType or "N/A"))
print("Cost amount: " .. (json_attribution.costAmount or "N/A"))
print("Cost currency: " .. (json_attribution.costCurrency or "N/A"))
print("FB install referrer: " .. (json_attribution.fbInstallReferrer or "N/A"))
print("JSON response: " .. (json_attribution.jsonResponse or "N/A"))
end)
-- ...
adjust.initSdk({
appToken = "YourAppToken",
environment = "SANDBOX",
logLevel = "VERBOSE"
})

Get current attribution information

When a user installs your app, Adjust attributes the install to a campaign. The Adjust SDK gives you access to these attribution details for the current install. To retrieve this information, call the getAttribution method:

local adjust = require "plugin.adjust"
local json = require "json"
adjust.getAttribution(function(event)
local json_attribution = json.decode(event.message)
print("Tracker token: " .. (json_attribution.trackerToken or "N/A"))
print("Tracker name: " .. (json_attribution.trackerName or "N/A"))
print("Campaign: " .. (json_attribution.campaign or "N/A"))
print("Network: " .. (json_attribution.network or "N/A"))
print("Creative: " .. (json_attribution.creative or "N/A"))
print("Adgroup: " .. (json_attribution.adgroup or "N/A"))
print("Cost type: " .. (json_attribution.costType or "N/A"))
print("Cost amount: " .. (json_attribution.costAmount or "N/A"))
print("Cost currency: " .. (json_attribution.costCurrency or "N/A"))
print("FB install referrer: " .. (json_attribution.fbInstallReferrer or "N/A"))
print("JSON response: " .. (json_attribution.jsonResponse or "N/A"))
end)