Getting dynamic page ID into lightbox User Form database

Hi,

I have a dynamic page which displays different cycling holidays, I then have an enquiry button which opens a lightbox Form, for users to input email and name to enquire about the holiday. However I want to also capture the dynamic page ID in the form, so that I know which holiday the user was making an enquiry about.

I have tried to use the below code (and variants), which seems to run with no error in preview, however when i publish the site and then submit an enquiry (through the lightbox user form), the dynamic page ID does not go into the lightbox user form database. Whereas the other fields in the form do (ie the ones the user fills in like name an email).

I have created and included the lightbox form dataset on the page - in below screen shot it is called dataset2.

Any help much appreciated - have not been able to work out why it is not adding the ID to the database

The code I have been using is below. Where dataset2 is the User form database and ‘tourId’ is the field within that database where I want the ID to be populated.

import wixLocation from ‘wix-location’;
let id = wixLocation.path[1];
$w.onReady( function () {
$w(“#dataset2”).onReady( () => {
$w(‘#dataset2’).setFieldValue(‘tourId’, wixLocation.path[1]);
} );
} );