Set up Smart scripts
If you're running Web campaigns that lead to a user installing the app via a button or banner on your mobile website, you may lose information about the original referring source. With Smart Scripts running on your mobile website, you receive complete attribution information.
Before you begin
Here's what you need to know before getting started.
Requirements
- Admin and Editor permissions
- (Optional) Configure deep links in the Adjust SDK iOS | Android
Availability
Smart Scripts is available as an Add-on solution. Contact your Adjust representative or email sales@adjust.com if you wish to get access.
Create New Script
- Under Campaign Lab, select Smart Scripts.
- Select New Smart script.
Choose a Base Link
The Base link functions as a fallback Link token to which all attribution would be awarded, if there is no incoming traffic source, i.e. if the user arrived on the web landing page organically, and not from any campaign.
- Select your desired app from the dropdown.
- Choose a base link.
Map Parameters
Map the parameters that are picked up from the incoming URL and mapped onto the outgoing URL,i.e. the Adjust Link. For example, IF utm_campaign is present, its value will be mapped onto the Adjust campaign parameter. If it doesn’t exist, the default fallback value defined by you will be used.
Map Partners
Map the partners and corresponding link tokens to which attributions should be awarded if they are the traffic source. For example, if the traffic source is Facebook (Meta) web campaigns (determined based on whether fbclid or fbpid is available on the incoming URL), then the corresponding network link token gets the attribution.
Note : If you're using Smart scripts to attribute web-to-app traffic for a partner, then you do not need to set up the Adjust tracking link within the partner dashboard (in the final URL or tracking template fields). You simply need to set up the campaign to redirect the user to the landing page URL with the right parameters (e.g. UTMs) appended. This is because the Adjust link with the right link token is now generated by the script and placed behind the CTA on the landing page. Setting up both methods of tracking might produce duplication of clicks and reporting inconsistencies.
Deploy Script
1. Copy script
Once the script is generated, you are taken to the ‘Script view’ page, where you can click the ‘Copy script’ button.
2. Deploy script
1. Embed the Script in your website
- Send the script to your web developer to implement.
- Tell them what to do with the Adjust link (outgoing URL) generated by the Smart scripts. For example, place them behind the ‘Download app’ button/CTA OR present a QR code on your Desktop website.
2. Deploy Script via Google Tag manager
- Navigate to Google Tag Manager.
- Select Tags -> New.
The implementation is up to your developers, but we'd recommend creating two tags:
First Tag to "Load Smart Script"
<script>
// Paste content of adjust-smart-script.min.js here
</script>
Second Tag to "Create Link and attach to Download" button
<script>
// Then configure mapping and call AdjustSmartScript.createLink
</script>
- Select Tag Configuration, then select Custom HTML and add a
<script>
in it. - You may need to configure the Tag firing/Initialization options to trigger only on specific web-to-app landing pages (not every single page of your website).
- Fire the "Load Smart Script" tag first (triggered once per page).
- Then fire the "Create Link and Attach to Download Button" tag. The script will return the Outgoing URL / Adjust link and you can embed this link behind your download button.
- Once fully implemented, when the user clicks on the "Download" button on the web landing page, the Adjust link will route user and attribute any app conversions back to the original source of web traffic.
Optional - Update Script
If you choose to edit the Smart script after deploying it on your website, your developer must manually redeploy/update your script for the changes to take effect. This does not happen automatically.
Test Smart Scripts
Smart Scripts outputs its logs in the browser's console. We recommended that you test how the script works with the specified mapping and ensure that correct links are generated.
- In your browser, go to the Developer Tools console.
- Navigate to the web page where you've implemented Smart Scripts.
- If there are no logs with the [adjust-smart-script] prefix, refresh the page. If you still don't see any logs, ensure that:
- Your code doesn’t suppress logging by calling AdjustSmartScript.setLogLevel('error') or AdjustSmartScript.setLogLevel('none').
- Your code calls the AdjustSmartScript.createLink(params) function.
With different values of the inputUrl property, you can test different use cases. For example, if you're running a Meta campaign and you also expect organic users to visit your landing page, you can have the a URL with the campaign and Meta parameters, and another URL without any additional parameters.
Example logs:
[adjust-smart-script]: Use defaultLinkToken to create adjust link
[adjust-smart-script]: Found value for campaign is new_campaign
[adjust-smart-script]: Found value for adgroup is some_adset
[adjust-smart-script]: Found value for creative is logo_image
[adjust-smart-script]: Transformed value for ref_code is id+my_product
[adjust-smart-script]: Misconfigured deep link: no valid androidAppSchema provided```