Edit your Smartserve prescript

In this article...

We'll show you how you can use your pre-script to run some JavaScript before any data collection or experience activation begins.

What is the pre-script?

The smartserve pre-script can be used to run some JavaScript before any data collection or experience activation begins.

It allows you to implement a wide range of bespoke use cases, tailored to your specific requirements. Examples include:

  • Tracking experience shown events in your third party analytics solution
  • Preventing smartserve from firing based on specific conditions (e.g. a cookie value or URL parameter)
  • Synchronizing Qubit segment membership changes to a third party
  • Setting up a QProtocol data layer mapper

TIP: You can also manage your script through the Qubit CLI.

Open the prescript

▸ Select Settings from the side menu and then Edit in the *Prescript** card.

Edit the prescript

▸ Make sure that you've selected prescript.js from the side menu:

pre-script

▸ Make the required changes and select Save You can now return to the previous page by selecting X in the top-right hand corner

TIP: For some examples of how the prescript can be used, see Code examples.

INFO: To publish your changes, you will need to review and apply them.

Review and publish your changes

When you or a member of your team has made changes to the prescript, those changes need to be reviewed and applied before they can be published. We'll notify you when there are changes ready for review.

In the following example, we see that there are unpublished changes and that the changes were made on October 17:

review-changes

▸ To review those changes, select Review and apply changes

So you can see what has been changed, we display a diff. In the following example, we see that a change was made on line 10:

changes-made

▸ Enter a reason for the change. Be as descriptive as possible to help other team members understand why the change was made

▸ Select Publish

View a changelog

So you and your team can keep track of changes to the prescript, we provide a revision history that you can browse through.

▸ To view the changelog, select Revision history. In the following example we see that there have been 4 revisions:

revision-history

▸ You can now select a revision to see the changes in a diff and the reason. Select Previous revision and Next revision to cycle through the changes. To return to the revision history, select Revision history

Last updated: February 2021
Did you find this article useful?