Title: before tracking init: Wrong characters
Last modified: August 21, 2016

---

# before tracking init: Wrong characters

 *  [Antoine Brunel](https://wordpress.org/support/users/antoinet/)
 * (@antoinet)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/before-tracking-init-wrong-characters/)
 * Hello,
 * In “Additional tracking code ( before tracker initialization )”, I write the 
   following code, (from a notepad that removes all the formatting just in case):
 *     ```
       function getUrlParameters(parameter,decode){var currLocation=window.location.search;var paramList=currLocation.split("?")[1];if(!paramList){return false;}
       var parameters=paramList.split("&");var returnBool=true;for(var i=0;i<parameters.length;i++){param=parameters[i].split("=");if(param[0]==parameter){return(decode)?decodeURIComponent(param[1]):param[1];returnBool=true;}
       else{returnBool=false;}}
       if(!returnBool){return false;}}
       var source=getUrlParameters('utm_source',true);var medium=getUrlParameters('utm_medium',true);_gaq.push(['_setCustomVar',2,'Fuente-medio',source+'-'+medium,1]);
       ```
   
 * However, what appears in the source code in a browser is different, with strange
   characters:
 *     ```
       <script type="text/javascript">var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-16677640-3']);_gaq.push(['_addDevId','i9k95']);function getUrlParameters(parameter,decode){var currLocation=window.location.search;var paramList=currLocation.split('?')[1];if(!paramList){return false;}
       var parameters=paramList.split('&');var returnBool=true;for(var i=0;i<parameters.length;i++){param=parameters[i].split('=');if(param[0]==parameter){return(decode)?decodeURIComponent(param[1]):param[1];returnBool=true;}
       else{returnBool=false;}}
       if(!returnBool){return false;}}
       var source=getUrlParameters('utm_source',true);var medium=getUrlParameters('utm_medium',true);_gaq.push(['_setCustomVar',2,'Fuente-medio',source+'-'+medium,1]);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();</script>
       ```
   
 * _[Moderator Note: Please post code & markup between backticks or use the code
   button. Your posted code may now have been permanently damaged by the forum’s
   parser.]_
 * That causes a javascript crash, you can see that here: [http://seotrafico.com/](http://seotrafico.com/)
 * And it is not a server problem since the strange characters do not appear on 
   a static page, and the code runs flawlessly without crashing: [http://seotrafico.com/getUrlParameters.html](http://seotrafico.com/getUrlParameters.html)
 * This problem has been reproduced on 2 different web servers (both running on 
   nginx though).
 * Thanks for your help!
 * [https://wordpress.org/plugins/google-analyticator/](https://wordpress.org/plugins/google-analyticator/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [Antoine Brunel](https://wordpress.org/support/users/antoinet/)
 * (@antoinet)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/before-tracking-init-wrong-characters/#post-4787402)
 * In response to the moderator note, the characters I mention do not appear when
   I post on the forum. (ASCII characters maybe or an encoding problem, for example&
   amp). They appear in view-source in Chrome, and in an HTML editor:
 *     ```
       <script type="text/javascript">var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-16677640-3']);_gaq.push(['_addDevId','i9k95']);function getUrlParameters(parameter,decode){var currLocation=window.location.search;var paramList=currLocation.split('?')[1];if(!paramList){return false;}
       var parameters=paramList.split('&');var returnBool=true;for(var i=0;i<parameters.length;i++){param=parameters[i].split('=');if(param[0]==parameter){return(decode)?decodeURIComponent(param[1]):param[1];returnBool=true;}
       else{returnBool=false;}}
       if(!returnBool){return false;}}
       var source=getUrlParameters('utm_source',true);var medium=getUrlParameters('utm_medium',true);_gaq.push(['_setCustomVar',2,'Fuente-medio',source+'-'+medium,1]);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();</script>
       ```
   
 *  Thread Starter [Antoine Brunel](https://wordpress.org/support/users/antoinet/)
 * (@antoinet)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/before-tracking-init-wrong-characters/#post-4787472)
 * To be even more specific in my question:
    Why does the same javascript code work
   when [introduced on a static HTML page](http://seotrafico.com/getUrlParameters.html)
   but crash when [introduced in Google Analyticator “before tracker initialization textbox”](http://seotrafico.com)?
 *  Thread Starter [Antoine Brunel](https://wordpress.org/support/users/antoinet/)
 * (@antoinet)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/before-tracking-init-wrong-characters/#post-4787484)
 * So why is Google analyticator textbox adding HTML characters?
    That is the question…
 *  Thread Starter [Antoine Brunel](https://wordpress.org/support/users/antoinet/)
 * (@antoinet)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/before-tracking-init-wrong-characters/#post-4787538)
 * I’m sorry to say that I don’t see much support for this plugin.
    I think I’ll
   try Google Analytics for WordPress…
 * _[Moderator Note: [No bumping](http://codex.wordpress.org/Forum_Welcome#No_Bumping),
   thank you.]_

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘before tracking init: Wrong characters’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/google-analyticator_fefefe.svg)
 * [Analyticator](https://wordpress.org/plugins/google-analyticator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analyticator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analyticator/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analyticator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analyticator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analyticator/reviews/)

## Tags

 * [encoding](https://wordpress.org/support/topic-tag/encoding/)

 * 4 replies
 * 1 participant
 * Last reply from: [Antoine Brunel](https://wordpress.org/support/users/antoinet/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/before-tracking-init-wrong-characters/#post-4787538)
 * Status: not resolved