Docs
As explained in another article, the Convertize Pixel is synchronous to avoid a flickering effect when loading the web page.
However, Convertize does allow the user to change the Pixel from synchronous to asynchronous.
Loading the Pixel asynchronously
To allow the page to load at the same time as the Convertize Pixel, you must add the attribute “async” in the Pixel between “.js
” and “></script>
” leaving a white space before “async” as shown below in “Example #2: asynchronous Pixel”.
Loading the Pixel after the page has loaded
Sometimes you may need to wait for the complete page to load before fetching the Convertize Pixel. Both the original code and the asynchronous method mentioned previously will hide the page content as soon as the Pixel is retrieved to apply your experiments, then show the content when the page is fully loaded.
If you have many JavaScript and CSS files being loaded, there could be a delay before content is shown. To avoid this delay, you can use the long version of the Pixel as shown below in “Example #3: long version asynchronous Pixel (modified by the user)”.
However, please note with this method the user is likely to see the original content briefly before the scenario is applied.
Examples
Example #1: synchronous Pixel (given by Convertize)
<script src="//pixel.convertize.io/1177.js" charset="UTF-8"></script>
Example #2: asynchronous pixel (modified by the user)
<script src="//pixel.convertize.io/1177.js" charset="UTF-8" async></script>
Example #3: long version asynchronous Pixel (modified by the user)
<script>
//<![CDATA[
(function() {
function asyncLoad() {
var urls = ["\/\/pixel.convertize.io\/1177.js"];
for (var i = 0; i < urls.length; i++) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.charset='UTF-8';
s.src = urls[i];
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
}
window.attachEvent ? window.attachEvent('onload', asyncLoad) : window.addEventListener('load', asyncLoad, false);
})();
//]]>
</script>
If you want to use any of these examples, copy and paste the script given in this article but do not forget to change the number “1177” used in the examples. You should replace it with your personal project number found in the Pixel code given to each of your projects.
Browser support
The first browser versions that fully support the attribute are Firefox 3.6, Internet Explorer 10.0, and all versions of Google Chrome, Safari, and Opera.