Introduction
The purpose of this widget is to allow customers to search for their tickets directly from the widget.
Customers will no longer need to start their search via OnTrack Retail's Booking Engine. Instead, once a fare search has been conducted, the widget will redirect the customer to the search results page, from where they can then continue with their booking process.
There is also the option to present the customer with their previously saved favourite tickets in order to quickly rebook tickets for their most popular journeys, providing they are logged into their account.
Installation
Script version
This is the recommended method of installation as it offers the best performance and the most features.
Step 1
Place an empty element on your page that will be used to contain the widget:
<div id="otrl-jp-widget"></div>
Value of id
is configurable, see Widget Options table.
Step 2
Include the following script
tag at the bottom of your page:
<script src="https://widgets.otrl.io/jp-widget/bundle.min.js"></script>
Step 3
Add a new script
tag after the external script resource included during the previous step:
<script>
OtrlJPWidget.init({
id: 'otrl-jp-widget',
redirectUrl: 'https://ticket.thameslinkrailway.com',
apiUrl: 'https://api.thameslinkrailway.com',
stylesheetUrl: 'https://widgets.otrl.io/jp-widget/brands/thameslink.css',
vertical: true
});
</script>
See Widget Options table for configuration options.
Iframe version
If the script version is not a possibility, this version will serve the widget inside an iframe.
Step 1
Include the following script
tag on your page where the widget should be displayed:
<iframe
allow="geolocation"
id="otrl-jp-widget"
src="https://widgets.otrl.io/jp-widget/?id=iframe&redirectUrl=https://ticket.thameslinkrailway.com&apiUrl=https://api.thameslinkrailway.com&stylesheetUrl=https://widgets.otrl.io/jp-widget/brands/thameslink.css&vertical=true&disabledTabs=''&enableModalHeightResize=true"
class="otrl-iframe-widget"
scrolling="no"
style="
width: 375px;
height: 550px;
border: none;
max-width: 375px;
background: transparent;
overflow: hidden;
"
title="JP widget"
onload="(function () { var widget = event.target; window.addEventListener('message', function (event) { if (event.data.action === 'iframe-otrl-jp-widget__resize') { widget.style.height = Math.round(event.data.height) + 'px'; } })})();"
>
</iframe>
Configure the widget by appending your options to the src
attribute's query component in key-value pairs.
See Widget Options table for configuration options.
Demo
Vertical
Script version: |
Iframe version: |
Script version (all features enabled): |
Horizontal
Script version only: |
Configuring the Favourites tab
When configuring your widget options, be sure to add the brand
widget option, as well as enable the Favourites tab by updating the disabledTabs
widget option:
Script version
<script>
OtrlJPWidget.init({
id: 'otrl-jp-widget',
brand: 'TL',
redirectUrl: 'https://ticket.thameslinkrailway.com',
apiUrl: 'https://api.thameslinkrailway.com',
stylesheetUrl: 'https://widgets.otrl.io/jp-widget/brands/thameslink.css',
vertical: true,
disabledTabs: 'OTHER'
});
</script>
Vertical: |
Horizontal: |
Iframe version
<iframe
allow="geolocation"
id="otrl-jp-widget"
src="https://widgets.otrl.io/jp-widget/?id=iframe&brand=TL&redirectUrl=https://ticket.thameslinkrailway.com&apiUrl=https://api.thameslinkrailway.com&stylesheetUrl=https://widgets.otrl.io/jp-widget/brands/thameslink.css&vertical=true&enableModalHeightResize=true&disabledTabs=OTHER"
class="otrl-iframe-widget"
scrolling="no"
style="
width: 375px;
height: 550px;
border: none;
max-width: 375px;
background: transparent;
overflow: hidden;
"
title="JP widget"
onload="(function () { var widget = event.target; window.addEventListener('message', function (event) { if (event.data.action === 'iframe-otrl-jp-widget__resize') { widget.style.height = Math.round(event.data.height) + 'px'; } })})();"
>
</iframe>
Vertical only: |
Widget Options
Below are a list of options available to customise the widget. Include any of these when configuring the widget during the installation steps:
Name | Type | Required | Default | Description | Example | Limitations |
---|---|---|---|---|---|---|
id |
String | Yes | -- | ID of the element where the widget will be injected. | "otrl-custom-horizontal" |
-- |
redirectUrl |
String | Yes | -- | Redirect page after performing the search. | "https://ticket.thameslinkrailway.com" |
-- |
apiUrl |
String | Yes | -- | API url where the search query will be executed. | "https://api.thameslinkrailway.com" |
-- |
stylesheetUrl |
String | Recommended | -- | The stylesheet URL used to brand the widget's look & feel. Use one of the default brand stylesheets or supply a custom stylesheet URL. Without this option, the widget will fallback to its own grey colour scheme. |
"https://static.thameslinkrailway.com/styles/jp-widget.css" |
Must be a valid URL |
brand |
String |
No (required for Favourites tab) |
-- | The shortcode format of the TOC brand. | "TL" |
"SE" ,
"TL" ,
"SN" ,
"GN"
|
redirectEnvironment |
String | No | "production" |
The environment of the brochure site to be redirected back to when logging into your account via the Favourites tab. | "staging" |
"production" ,
"staging"
|
vertical |
Boolean | No | false |
Horizontal version (Script) or vertical version (Script & Iframe). | true |
true ,
false
|
darkMode |
Boolean | Yes | false |
Enable when supplying a dark mode specific stylesheetUrl. | true |
true ,
false
|
searchCallBack |
Function | No | null |
A callback function that will return you the current search url and the form data. | (url, data) => console.log(url, data) |
Only script mode |
from |
String | yes | null |
Sets the default destination station for Tickets and Season tabs. | "1072" |
Must be a valid NLC station code. |
to |
String | yes | null |
Sets the default destination station for Tickets and Season tabs. | "1072" |
Must be a valid NLC station code. |
defaultValues |
Object | No | null |
A customisable object to provide default values to forms. | See Acceptable schemas section. | Only script mode |
tabsStyle |
String | yes | "PANEL" |
Visual style of the tabs | "BUTTON" |
"PANEL" ,
"BUTTON"
|
activeTab |
String | No | "TICKETS" |
Current active tab | "FAVOURITES" |
"TICKETS" ,
"SEASON" ,
"OTHER" ,
"FAVOURITES"
|
hideNavigation |
Boolean | No | false |
Hide the top menu which allows users to navigate between ticket types. | true |
true ,
false
|
hideSubNavigation |
Boolean | No | false |
Hide the sub menu inside the 'Other' tab which allows users to navigate between ticket types. | true |
true ,
false
|
disableBackground |
Boolean | No | false |
By default, the JP widget uses a gray background, you can disable it and use the inherited background. | true |
true ,
false
|
hidePromotionalText |
Boolean | No | false |
Hide the message "No booking fees!". | true |
true ,
false
|
disabledTabs |
String | No | "OTHER,FAVOURITES" |
List of disabled tabs (comma separated). | "OTHER" |
-- |
enableDaySave |
Boolean | No | false |
Enable the ticket type: Day Save | true |
true ,
false
|
enableRoversRangers |
Boolean | No | true |
Enable the ticket type: Rover | false |
true ,
false
|
enableKentRover |
Boolean | No | false |
Adds a Kent Rover option for Rover ticket type | true |
true ,
false
|
enableSmartCarnet |
Boolean | No | false |
Enable the ticket type: Smart Carnet | true |
true ,
false
|
enableFlexi |
Boolean | No | true |
Enable the ticket type: Flexi Season | false |
true ,
false
|
googleTagManagerId |
String | No | null |
Google Tag Manager ID (analytics) | "GTM-WMQGG2P" |
-- |
dataLayerName |
String | No | null |
Data Layer Variable name (analytics) | "dataLayer" |
-- |
disabledRailcards |
String | No | "" |
List of railcard codes to exclude from selection (comma separated) | "TST,YNG" |
"2TR" ,
"DIC" ,
"DIS" ,
"FAM" ,
"HMF" ,
"JCP" ,
"NEW" ,
"NGC" ,
"SRN" ,
"TST" ,
"VET" ,
"YNG"
|
popularStationsList |
String | No | "none" |
Prepopulates the list of popular stations with the predefined list for brands | "southeastern" |
"none" ,
"southeastern" ,
"gtr"
|
utmCampaign |
String | No | "" |
Defines the utm_campaign query param that will be appended to the redirectUrl. As a fallback - if utmCampaign is not provided - it will use the page's (or iframe parent's) hostname. |
"southeastern" |
"" ,
"southeastern" ,
"gtr"
|
utmContent |
String | No | "" |
Defines the utm_content query param that will be appended to the redirectUrl. | "JP Widget" |
-- |
utmMedium |
String | No | "" |
Defines the utm_medium query param that will be appended to the redirectUrl. | "web" |
-- |
utmSource |
String | No | "" |
Defines the utm_source query param that will be appended to the redirectUrl. | "brochure" |
-- |
closeModalWithBackButton |
Boolean | No | false |
Enable modal dialogs to be closed with the browser "back" button. | true |
This hooks into the browser's History API and manipulates the user's session history when opening/closing a modal dialog. Use with caution when embedding the widget in an SPA with a history-based router. |
enableModalHeightResize |
Boolean | No | false |
Enable iframe resize events to consider the height of modal dialogs | true |
-- |
gatwickRoutes |
Boolean | No | false |
Enable for gatwick express routes | true |
true ,false |
enableBestFareFinderAndRecentOrders |
Boolean | No | false |
Enable Recent Orders for logged in users and Best Fare Finder for guests | true |
true ,false |
enablePromoDiscount |
Boolean | No | false |
Enable Discount codes feature | true |
true ,false |
Acceptable schemas
The JSON schemas for each ticket type to be used for the defaultValues
option.
Ticket type | Schema |
---|---|
Smart Carnet |
|
Day Save |
|
Rovers & Rangers |
|
Theming
Default brand stylesheets
Below are the default stylesheets for each brand. These can be used for the stylesheetUrl
option when configuring the widget.
-
Southeastern:
https://widgets.otrl.io/jp-widget/brands/southeastern.css
-
Thameslink:
https://widgets.otrl.io/jp-widget/brands/thameslink.css
-
Southern:
https://widgets.otrl.io/jp-widget/brands/southern.css
-
Great Northern:
https://widgets.otrl.io/jp-widget/brands/greatnorthern.css
-
Gatwick Express:
https://widgets.otrl.io/jp-widget/brands/gatwick.css
Colours
The default stylesheets for each brand use CSS variables to define the colours used throughout the widget.
To change these colours:
- Create a custom stylesheet by copying one of the original branded CSS stylesheet
- Make the necessary changes
- Host the file
- Set the
stylesheetURL
option to the URL of your hosted stylesheet file