Start Free trial

How to Use VWO for Single Page Applications

Follow

Comments

4 comments

  • Martin Christensen

    What kind of bull-crap is:

    returnuse_existing_jquery;

    And the many other space-removed-type errors in the snippet.

    I mean, if you expect people to just copy/paste your code, please at least make it valid.

    Even when fixing these obvious mistakes in the (DO NOT EDIT BELOW THIS LINE) part of the snippet, it still leaves you with a feeling of dubious confidence in the script-authors sanity.

    Why must 3rd-party code be not just obfuscated but near idiotic?

    1
    Comment actions Permalink
  • Vaibhav Singh

    Hi Martin,

    Thank you for bringing this to our attention.

    Apologies for the code block issue as it didn't work as promised. We understand your disappointment towards this, and for now, we have fixed the code block.

    Going forward, we will keep track of such things and will make sure that this does not happen again. 

    Best Regards,
    Vaibhav.

    0
    Comment actions Permalink
  • Ross Joo

    Is there a way to know when VWO detects a SPA history change, like some sort of lifecycle event that we can hook into?

    Basically looking into ways of reverting non CSS changes.

    0
    Comment actions Permalink
  • Vaibhav Singh

    Hi Ross,

    VWO detects the URL change using history.pushState API. To know more about this API, you may refer to https://developer.mozilla.org/en-US/docs/Web/API/History/pushState.

    For reverting the non-CSS changes, you can write custom JS code in the code editor. It means you can look for a condition on the respective page and if that condition satisfies, you can then revert the non CSS changes. If you are looking for an event, you can write the custom JS code to revert the changes manually on the specific event such as TEST_NOT_RUNNING (tNR) event.

    Below is a sample code for your reference. You can use this event to do something when the test is not running on the page. You can listen to TEST_NOT_RUNNING (tNR) event.

    VWO.push(['onEventReceive', 'tNR', function (data) {
        var eventName = data[0]; // data[0] will always contain the event Name
        // Other data parameter changes according to the event
        var experimentId = data[1];
    // Do something
    }]);

    In case you need further assistance on this, please reach out to us at support@vwo.com.

    Thanks,
    Vaibhav Singh.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.