Sign in

Welcome.
How can we help?

Can I use the Freespee script in my single-page app?

Topic: , Updated:

Yes, but you will need to manually trigger an execution when a new page is loaded. This can be done using the trackPage method on the __fs_dncs_instance object.

In the root of your project add the snippet as usual but halt execution by adding the autoInvoke=false option.

<script type="text/javascript">
    var __fs_conf = __fs_conf || [];
    __fs_conf.push(['setAdv',{'id':'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}]);
    __fs_conf.push(['autoInvoke', false]);
</script>
<script type="text/javascript" src="//url/js/external/fs.js"></script>

On every page load (including the initial one) you then need to run __fs_dncs_instance.trackPage().

For example, if you're using AngularJS you would put it in the $viewContentLoaded event:

myApp.run(['$rootScope', function($rootScope) {
    $rootScope.$on('$viewContentLoaded', function() {
        __fs_dncs_instance.trackPage();
    });
}]);
Was this article helpful?
0 out of 0 found this helpful

Comments


Not the answer to your question?

Powered by Zendesk