How to insert JavaScript codes in articles?

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.

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.

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 that will surround our text:

kot java script w artykulach html

The last step is to paste the traffic tracking code, preferably at the very end of the article.

Correctly pasted code looks like this:

kod java script w artykułach

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.

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

  • 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 administrator of personal data is WhitePress Publishing LTD with its registered office at 590 Kingston Road, London SW20 8DN, your personal data is processed for the marketing purpose of WhitePress sp.z o.o. and entities interested in marketing their own goods or services. Marketing objective of WhitePress sp.z o.o. includes commercial information about conferences and trainings related to content published in the Knowledge Base tab.

The legal basis for the processing of your personal data is the legitimate purpose pursued by the Administrator and his partners (Article 6 paragraph 1 point f of the GDPR).

Users have the following rights: the right to request access to their data, the right to rectify it, the right to delete data, the right to limit processing and the right to transfer data. You can find more information about the processing of your personal data, including your rights, in our privacy policy.
Read all
  • No comments on this article yet.
The administrator of personal data is WhitePress Publishing LTD with its registered office at 590 Kingston Road, London SW20 8DN, your personal data is processed for the marketing purpose of WhitePress sp.z o.o. and entities interested in marketing their own goods or services. Marketing objective of WhitePress sp.z o.o. includes commercial information about conferences and trainings related to content published in the Knowledge Base tab.

The legal basis for the processing of your personal data is the legitimate purpose pursued by the Administrator and his partners (Article 6 paragraph 1 point f of the GDPR).

Users have the following rights: the right to request access to their data, the right to rectify it, the right to delete data, the right to limit processing and the right to transfer data. You can find more information about the processing of your personal data, including your rights, in our privacy policy.
Czytaj całość
Recommended articles