It is no secret that the Baidu Link Submission Script is an effective tool for surfacing links that are not quite visible to Baidu spiders. In Baidu’s own words (translated from Chinese):
The JavaScript snippet pushes links to Baidu directly; it serves all platforms, as well as both desktop and mobile devices. Your page is discovered by Baidu the moment of its first page view, which accelerates the progress of new content discovery.
By inserting the snippet into the source code of pages that you want Baidu to discover and index, it pushes the URL of the current page to Baidu automatically.
How the script works
The script simply checks the protocol of your page and selectively downloads a JavaScript (JS) file from Baidu. It copies the script in the file and creates a node of <script> on your page. The copied script then takes the URL of the current page, plus the referrer URL of the page, as the parameters when requesting a GIF file (a 1×1 pixel GIF for carrying the parameters) from Baidu.
Every time a visitor browses the page, the script is executed and Baidu will be notified. For example, if you were to drive a considerable amount of traffic to the pages, Baidu would know how important and popular the content is.
As you can see, the code snippet is straightforward and open to other configurations. For example, you may use it as an impression-tracking pixel. That gives us reason to believe that it won’t get high priority at Baidu. To be honest, we don’t think this will improve your ranking on Baidu. However, it does help the indexation of your site to some extent.
How we improved it
As a veteran of SEO, you may have noticed that submitting the URL of the current page does not follow the best practices, because:
- the URL may not be the canonical URL you want the engine to index.
- the script makes an extra request which is unnecessary and potentially slows down the page load speed.
- furthermore, those two JS files are static and are mostly identical, except the URL of the GIF you are requesting.
In order to tackle those issues, my colleague Woody Chai and I have tweaked the Baidu script a bit. See the code snippet below.
In the code snippet above, we added a step to check if the canonical directive exists and hard-copied the script by merging those two JS files. Now, we can push the canonical URL to Baidu by only one HTTP(S) request.
Last thoughts
In this example of the improved Baidu Link Submission Script, we have demonstrated how we can make the script Baidu gave us more SEO-friendly. There is one thing you should keep in mind: The scripts (including the URL of the GIFs Baidu put in those JS files) may be changed in the future, though it hasn’t changed since day one. If you find any 404s of those resources, or any sign that the script is lagging the page load speed, you should go back to Baidu Webmaster Tools for updated solutions.