|Help Centre

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

Last updated at

Yes, but you will need to trigger an execution when a new page is loaded manually. It 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(['autoInvoke', false]);
<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() {

Can't find what you're looking for?