How Can I Extract Specific Parameters from QR Code URLs?

Last updated: Oct 16th 2025

A logistics coordinator recently reached out with a common challenge: their team scans PostNL tracking QR codes that contain full URLs with multiple parameters, but they only needed to extract a single tracking number from the URL string. The QR codes contained URLs like https://postnl.nl/tracktrace/?D=NL&B=3SKAAG286384902&P=5991PT&L=NL&T=C&C=k-pnl_p-pnl_u-red_r-qrcode, and they wanted to capture just the value of the B parameter (in this case, 3SKAAG286384902) without typing it manually or processing the entire URL.

This is a perfect example of how Barcode to PC can streamline shipping and logistics workflows by automatically parsing QR code data and extracting only what you need.

What Is the Solution for Extracting URL Parameters?

Barcode to PC solves this using Output Templates, which let you define a sequence of components that process scanned data. For URL parameter extraction, you need just two components working together:

  • BARCODE component: Captures the QR code containing the full URL
  • JAVASCRIPT_FUNCTION component: Extracts the specific parameter you need

The beauty of this approach is that it happens automatically on every scan. Your team scans the QR code once, and the system outputs only the tracking number, ready to be typed into your logistics software or saved to a spreadsheet.

How Do You Set Up URL Parameter Extraction?

Setting up this workflow takes just a few minutes in the Barcode to PC server settings:

Step 1: Add the BARCODE component
Start by adding a BARCODE component to your Output Template. This component opens the camera on your smartphone to scan the QR code. Once you’ve added it, enable the “Skip output” option since you don’t want to output the full URL, just the extracted parameter.

Step 2: Add the JAVASCRIPT_FUNCTION component
Next, add a JAVASCRIPT_FUNCTION component right after the BARCODE component. This is where the magic happens. In the function field, add this simple code:

new URL(barcode).searchParams.get('B')

This JavaScript code takes the scanned barcode (which contains the full URL), creates a URL object from it, and extracts just the B parameter. For PostNL tracking codes, this returns exactly what you need: the tracking number.

Step 3: Test and deploy
Save your Output Template and test it by scanning one of your tracking QR codes. You should see only the tracking number appear on your computer, not the entire URL.

Can This Work with Different URL Parameters?

Absolutely. The same technique works for any URL parameter in any QR code. If you scan QR codes from different carriers or systems, you can easily modify the JavaScript code to extract different parameters.

For example, if you need to extract an order ID parameter called order_id from a URL like https://example.com/?user_id=123&order_id=456&status=pending, you would simply change the code to:

new URL(barcode).searchParams.get('order_id')

You can even create multiple Output Templates for different workflows, each extracting different parameters based on your specific needs.

What If I Need Multiple Data Points from the Same QR Code?

Sometimes you might need to extract several parameters from a single QR code. Maybe you need both the tracking number and the postal code from your PostNL QR codes. This is straightforward with Barcode to PC.

Simply add multiple JAVASCRIPT_FUNCTION components to your Output Template, each extracting a different parameter. For the PostNL example:

First JAVASCRIPT_FUNCTION (for tracking number):

new URL(barcode).searchParams.get('B')

Second JAVASCRIPT_FUNCTION (for postal code):

new URL(barcode).searchParams.get('P')

Each component creates a separate column in your CSV output file, so you can track multiple data points simultaneously. This becomes especially useful when you’re building inventory systems or tracking shipments across multiple stages.

How Does This Improve Your Workflow?

Before implementing this solution, the logistics team would have to manually copy the tracking number from the full URL or type it into their system, a process prone to errors and time-consuming when handling dozens or hundreds of packages daily.

With Barcode to PC handling the parameter extraction automatically, here’s what changes:

  • Speed: Scan once and the tracking number is immediately available, no manual copying or typing required
  • Accuracy: Zero transcription errors since the system extracts the exact parameter value
  • Flexibility: Output can go directly to your keyboard (using Keyboard Emulation) to fill forms, or to a CSV file for batch processing
  • Scalability: Handle hundreds of packages with the same effort as handling ten

This approach also works perfectly with Android PDA devices commonly used in warehouses, making it easy to deploy across your entire logistics operation.

What Other Data Extraction Scenarios Are Possible?

URL parameter extraction is just one example of how the JAVASCRIPT_FUNCTION component can transform scanned data. The same approach works for many other scenarios logistics and warehouse teams face daily:

  • Extracting parts of structured barcodes: If your barcodes contain multiple pieces of information separated by delimiters (like LOC-A15-SKU123), you can split and extract specific segments
  • Removing prefixes or suffixes: Clean up barcode data by removing unnecessary characters before or after the actual data you need
  • Formatting dates: Convert date formats embedded in barcodes to match your system’s requirements
  • Validating and transforming data: Apply business rules to scanned data before it enters your system

If you’re not comfortable writing JavaScript, you can use AI tools like ChatGPT to generate the extraction code for you. Simply describe what you want to extract, and it will provide the JavaScript function you need. The JAVASCRIPT_FUNCTION documentation includes several examples of using AI to generate extraction code.

For teams managing shipments, tracking inventory, or processing packages, these automated data extraction capabilities turn your smartphone into a powerful data collection tool that integrates seamlessly with your existing systems. You get the scanning convenience of mobile devices with the precision and automation of enterprise software.


Filippo

Did this article help you?

Yes
Please, describe your problem at [email protected] and we'll be glad to help you

Related posts