How to insert JavaScript codes in articles?

Updated on: 2022-03-04
JavaScript codes
Advertisers' requirements are increasing. Most agencies want to measure the effectiveness of their activities, including the publication of articles. This requires embedding the appropriate code, which is not always easy. In this article, we will show you how to do it and what problems we may encounter. We will do it on the example of Content Management Systems commonly used in the administration panels of websites and portals.
Start earning money today.
Sign up for free

Traffic tracking and traffic analysis codes do not differ in the way they are inserted. Such code can be a script that counts traffic based on Google Analytics, an internal WhitePress® statistics system, or another proprietary solution. It is getting more popular that the code is to enable remarketing activities.

We want to show you, step by step, how to copy and paste the tracking script to the articles ordered by Advertisers. Since this code is always in java script, you can use some tips to implement the code properly.

1. Copy the tracking code

If you are a Publisher in WhitePress® and you have offers of articles with a tracking option, you probably get such an order sometimes. In an article like this, you will see the tracking code to copy, located at the bottom of the text: 

Tracking code in the article view

Copy this script by clicking the button and open your article website in other window.

1. Turn the view of your article editor to HTML 

All websites run on the basis of an HTML editor. To correctly place the javascript code in the body of the article, you must first switch to the HTML editing mode, i.e. the document source.

As you probably know, HTML view is very different from the usual view - for example in Wordpress blog the visual view of the article looks like this:

Visual view of the article - Wordpress

While the HTML view, which is placed under the "Text" button, looks like this:

Text view (HTML) in WordPress

Depending on the content editor used in the portal administration panel where the article is published, the buttons may look different. Sometimes you may need to find this option in the editor's menu or by right-clicking.

kod java script

After switching, we should see the HTML tags. We don't need to understand them, just make sure that there are acute <> brackets present in the text.

In next step, scroll the HTML text to the end. This is the place where the script should be pasted:

Where to paste the tracking code - WordPress screen

The last step is to paste the traffic tracking code. Correctly pasted code looks like this:

Java script tracking code in the article HTML view

After inserting the code, we can turn off the HTML source and save our article. If everything went well, the traffic tracking code will be included in the article body, and the statistics should count.

3. Common technical issues

Possible problems that should be consulted with the person technically responsible for the website:

  • In WordPress page, the pasted code is changing after saving. It happens a lot – JavaScript is not compatible with some WordPress versions, so you need to find a way to put the code outside the text view. One of the solutions is to use a special plugin: Embed code. Download the plugin to your WordPress and put the tracking code in the Custom Fields – for more specific instructions please read the description of the plugin.
  • Code pasting is disabled in the editor – the appropriate parameter must be set in the editor configuration.
  • The editor does not have any source switching button – an appropriate parameter must be added in the editor configuration.
  • After saving, the code is not inserted in the article. Perhaps the editor has a restriction in placing <script> tags in the content. You will need to change the options in the editor allowing for placing these tags).
  • After saving, the code looks the same, the quotation marks are changed (the editor may have the function of replacing quotation marks and angle brackets with entities that are only printable, but do not fulfill any function. You should disable the parameter responsible for converting special characters to entities in the editor configuration).
Your comments (0)
The WhitePress editors reserve the right to remove comments offensive to other people that contain vulgar words or do not relate to the subject matter of the subject matter.

The Controller of personal data of individuals using the whitepress.com website and all its subpages (hereinafter: the Service) within the meaning of Regulation (EU) 2016/679 of the European Parliament and of the Council of 27 April 2016 on the protection of natural persons with regard to the processing of personal data and on the free movement of such data, and repealing Directive 95/46/EC (hereinafter: GDPR) is collectively "WhitePress" Spółka z ograniczoną odpowiedzialnością with its registered office in Bielsko-Biała at ul. Legionów 26/28, entered into the Register of Entrepreneurs of the National Court Register kept by the District Court in Bielsko-Biała, 8th Economic Division of the National Court Register under the KRS number: 0000651339, NIP: 9372667797, REGON: 243400145 and the other companies from the WhitePress Group (hereinafter together: the Controller).


By registering for the newsletter, you consent to receiving commercial information via electronic communication means, especially email, regarding direct marketing of services and products offered by WhitePress Sp. z o.o. and its trusted business partners interested in marketing their own goods or services. The legal basis for processing your personal data is given consent (Art. 6 (1) (a) GDPR).


At any time, you have the right to withdraw your consent for the processing of your personal data for marketing purposes. For more information on the processing and legal basis for processing your personal data by WhitePress Sp. z o.o., including your rights, you can find in our Privacy Policy.

Read all
  • No comments on this article yet.

The Controller of personal data of individuals using the whitepress.com website and all its subpages (hereinafter: the Service) within the meaning of Regulation (EU) 2016/679 of the European Parliament and of the Council of 27 April 2016 on the protection of natural persons with regard to the processing of personal data and on the free movement of such data, and repealing Directive 95/46/EC (hereinafter: GDPR) is collectively "WhitePress" Spółka z ograniczoną odpowiedzialnością with its registered office in Bielsko-Biała at ul. Legionów 26/28, entered into the Register of Entrepreneurs of the National Court Register kept by the District Court in Bielsko-Biała, 8th Economic Division of the National Court Register under the KRS number: 0000651339, NIP: 9372667797, REGON: 243400145 and the other companies from the WhitePress Group (hereinafter together: the Controller).


By registering for the newsletter, you consent to receiving commercial information via electronic communication means, especially email, regarding direct marketing of services and products offered by WhitePress Sp. z o.o. and its trusted business partners interested in marketing their own goods or services. The legal basis for processing your personal data is given consent (Art. 6 (1) (a) GDPR). By submitting the form, you declare that you have read the Privacy Policy.


At any time, you have the right to withdraw your consent for the processing of your personal data for marketing purposes. For more information on the processing and legal basis for processing your personal data by WhitePress Sp. z o.o., including your rights, you can find in our Privacy Policy.

Read all
Recommended articles