Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it ok to load GA conversion script using jQuery .load()?
    primarykey
    data
    text
    <p>In the checkout process of an e-commerce site the same webpage is loaded for each step. However each step has an unique querystring value, e.g. <code>checkoutstep=confirmation</code>. In the final step I need to place a Google Analytics conversion script. I do this by dynamically loading a HTML page containing the GA script using jQuery <code>.load()</code>:</p> <pre class="lang-js prettyprint-override"><code>if (getParameterByName("checkoutstep") == "confirmation") { var placeholder = $('&lt;div id="ga"/&gt;').appendTo('body'); $(placeholder).load('ga.html'); } </code></pre> <p>And the contents of <code>ga.html</code>:</p> <pre class="lang-js prettyprint-override"><code>&lt;script type="text/javascript"&gt; /* &lt;![CDATA[ */ var google_conversion_id = XXX; var google_conversion_language = "en"; var google_conversion_format = "2"; var google_conversion_color = "ffffff"; var google_conversion_label = "XXX"; var google_conversion_value = 0; var google_remarketing_only = false; /* ]]&gt; */ &lt;/script&gt; &lt;script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"&gt;&lt;/script&gt; &lt;noscript&gt; &lt;div style="display:inline;"&gt; &lt;img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/XXX/?value=0&amp;amp;label=XXX&amp;amp;guid=ON&amp;amp;script=0"/&gt; &lt;/div&gt; &lt;/noscript&gt; </code></pre> <p>This <em>seems</em> to be working, but I know there are many things to consider. So my question is: is this a correct way to do? Is it ok to load the script using jQuery <code>.load()</code>?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload