# Opening a Mini Program By Scanning a Common Link QR Code

To allow Mini Program developers to promote Mini Programs more conveniently and ensure compatibility with existing offline QR codes, Weixin Official Accounts Platform provides the capability of navigating to Mini Programs by scanning common link QR codes.

# Feature Description

Common link QR codes refer to QR codes that are generated after developers encode web links via tools.

Offline merchants do not need to change offline QR codes. Instead, after configurations are complete in the Mini Program admin console, users can scan the common link QR codes to open Mini Programs and use features of the Mini Programs.

To navigate to Mini Programs, users can tap Scan on the Discover page of Weixin to scan common link QR codes, or tap and hold the common link QR codes in Weixin and select Extract QR Code in Weixin.

# Applicable Scope

Mini Programs owned by companies, media, governments, and other organizations

# QR Code Navigation Rules

Note: As of May 2017, the Weixin client supports subpath matching during configuration of a QR code rule. For example, the link to the original QR code is http://www.qq.com/a/123456, where 12345 is the service parameter. In this case, the rule can be configured as http://www.qq.com/a/, to allow users to navigate to the Mini Program by scanning the QR code.

During QR code scanning, the Weixin client will control navigation according to the following matching rules:

  1. The protocol and domain name in the QR code link must be consistent with those in the configured QR code rules.
  2. The QR code link belongs to the subpath of the QR code rule configured in the admin console. (If subpath matching needs to be supported, ensure that the configured QR code rule ends with a backslash (/).)
  3. If the QR code rule contains a parameter, the parameter is following the question mark ? in the link. The parameter in the rule and the parameter in the link must contain the same prefix.

Common matching errors:

QR Code Rule Configured in the Admin Console Complete Offline QR Code Link Error Cause
http://www.qq.com/a/b https://www.qq.com/a/b Protocols are different.
https://www.qq.com/a/b https://www.weixin.qq.com/a/b Domain names are different.
https://www.qq.com/a/b?id=123 https://www.qq.com/a/b?id=132 Parameter prefixes are different.
https://www.qq.com/a/b https://www.qq.com/a/bc The rule does not belong to the subpath.
https://www.qq.com/a/b https://www.qq.com/a/b/123 The rule does not end with a backslash (/). Therefore, subpath matching is not supported.

# Extracting Content from a QR Code

After the rule for navigating to a Mini Program by scanning a QR code is configured in the Mini Program admin console, users can open a Mini Program by scanning the QR code on Weixin 6.5.6 or later.

The content of the QR code link is displayed on the page as the q parameter. To obtain the complete content of the original QR code, extract the q parameter from the onLoad event and call decodeURIComponent once.

# Configuration Process

Log in to the Mini Program admin console and choose Settings > Development Settings. Enable Scan a Common Link QR Code to Open a Mini Program. Then, you can configure a QR code rule.

# QR Code Rule

According to QR code navigation rules, developers need to enter the rules for the QR codes that are to be navigated to Mini Programs. Specific requirements are as follows:

  1. Domain names in QR code rules must pass ICP license verification.

  2. Links prefixed with http, https, and ftp (for example, http://wx.qq.com, https://wx.qq.com/mp/, and https://wx.qq.com/mp?id=123) are supported.

  3. A maximum of 100 QR code prefixing rules can be configured for one Mini Program account.

# Rules for Using Prefixes Exclusively

Developers can choose whether to exclusively use all sub-rules that comply with the QR code matching rules. If they choose to use these sub-rules exclusively, other accounts cannot apply to use other sub-rules with the matched prefixes.

For example, if developer A configures a QR code rule as https://wx.qq.com/mp?id=123 and selects Use all sub-rules exclusively, other developers cannot configure sub-rules with matched prefixes, for example, https://wx.qq.com/mp?id=1234.

If the message indicating "This rule is already in use" appears, contact the Mini Program developer to resolve this issue.

# Verification File

To pass ownership verification, you need to download a random verification file and upload the file to a directory at a specified location on the server.

Rules for storing the verification file: Store the verification file in the last sub-directory declared in the URL. If there is no sub-directory, store it in the top-level directory of the server to which the host belongs. If a hint is displayed on the page, store the verification file in the specified directory.

# Feature Page of the Mini Program

Developers can configure the path to the feature page of the Mini Program that is displayed after a QR code is scanned, for example, pages/index/index.

# Testing and Debugging

Developers can test and debug configured QR code rules.

Testing takes effect only for specified test links and Weixin users who fall into the test scope. Other users can still be navigated to a web page after scanning a QR code, and use Mini Programs normally. After releasing the QR code rule, developers can still test a selected version (developer, test, or online version). Note that code submission is required if the developer version is to be opened.

# Test scope

To test the feature of navigating to Mini Programs by scanning common link QR codes, developers can select the developer, test, or online version based on the development progress.

Before testing, a developer must enter a complete QR code link that complies with a QR code prefix matching rule. If this link contains a parameter, provide the complete parameter.

You can enter a maximum of five test links for one rule, and they can be repeatedly modified. If a QR code matches a test link and a user's Weixin ID is that of an administrator, developer, or experiencer linked to a Mini Program, the specified version of Mini Program will be opened.

# Release

Developers can publish QR code navigation rules to the existing network after testing. Then, all QR codes that comply with matching rules will be navigated to the specified Mini Program page after being scanned.

To guarantee good user experience, Mini Program code must be released before QR code navigation rules for the Mini Programs.

A maximum of 100 QR code navigation rules can be released for a Mini Program account per month.