Execute function present on HTML element

Hi! :slight_smile: I’m trying to implement AppsFlyer’s Smart Script on my page. It basically helps you attribute the mobile app installs coming from your website (you can spot those installs as web-assisted rather than just as “organic”).

The thing is, it requires you to add a long JS code on your page, which I have done using an HTML element. And now it requires me to call this function that is inside such a code (which assigns the result URL to a variable called result):

//Call the function after embedding the code through a global parameter on the window object called window.AF_SMART_SCRIPT.
//Onelink URL is generated.
var result = window.AF_SMART_SCRIPT.generateOneLinkURL({
    oneLinkURL: oneLinkURL,
    webReferrer: webReferrer,
    afParameters: {
        mediaSource: mediaSource,
        campaign: campaign,
        afCustom: [
            utm_source,
            utm_medium,
            utm_campaign,
            utm_content,
            utm_term,
            custom_ss_ui
        ]
    }
});

How can I call this function? I was thinking of running some Javascript code on page load, but I’m not sure if I have to use the “Javascript to Bubble” element, and how to configure. Or if I just need to run some JS on page load and that’s all (and if so, which code).

Any ideas? Thanks!

P.S.: If anyone has implemented AppsFlyer’s Smart Link on their site, please let me know!

This topic was automatically closed after 70 days. New replies are no longer allowed.