Widget: page, campaign and hidden fields on a ticket

A ticket is easier to handle when you know where it came from. The Widget can record the page, the campaign or the customer plan in a custom field of the ticket and hide that field from the visitor. The values then work in issue filters, queries and reports, so support can see which page produces the most tickets and marketing can see which campaign brings requests.

Prepare custom fields

You need to be an administrator.

  1. Create issue custom fields of the type text, for example Source page and UTM campaign, and make them available for the trackers of your Widget projects. Do not make them required.
  2. Open Administration, then Helpdesk, then the Widget tab.
  3. Under Available custom fields check these fields. Only checked fields can be filled or shown by the Widget.
  4. Select Save.

Fill the fields from the page

var params = new URLSearchParams(location.search);
if (params.get('utm_campaign')) sessionStorage.setItem('utm_campaign', params.get('utm_campaign'));

hdwDataLayer.push({ identify: { customFieldValues: {
  'Source page': location.href,
  'UTM campaign': sessionStorage.getItem('utm_campaign') || ''
} } });

Every field that gets a value is filled and hidden from the visitor. The campaign parameters exist only on the landing page, so the example keeps them in sessionStorage for the rest of the visit.

Rules that keep the form working

  • Always send a value for a field you want hidden. An empty string '' keeps it hidden; null removes the key and the field shows.
  • Use optional text fields. A required field left empty stops the form without a visible message, and list or checkbox fields without a matching value stay visible.
  • Fields are matched by name. Renaming a custom field in Redmine breaks the page code until you update it.
  • Values travel in the address of the form, so they reach server logs. Send no personal data.
  • A visitor can change the values, so use them for reporting only.

Other things you can prefill

The same identify object fills the name, email, subject, project, tracker and category. A known customer then sees a form with only the description field left. See Data layer.

hdwDataLayer.push({ identify: {
  nameValue: customer.name,
  emailValue: customer.email,
  subjectValue: 'Question about order ' + order.id,
  trackerValue: 'Question',
  customFieldValues: { 'Plan': customer.plan }
} });

Use the data in Redmine

  • Add the custom fields as columns and filters to the ticket list, and save a query, for example "Tickets by source page".
  • Group by UTM campaign to see which campaign brings tickets.
  • Show the field on the issue so the agent sees the page the customer was on before writing.

Related articles

Was this article helpful? Yes  No