I have this tracking code, I am not sure what else I can do to it to make it fire. When the page loads nothing happens, no errors, I just don't see the data being sent to google.
<script>
if (hotelname == " foohotels")
{
document.write(<img height="1" width="1" border="0" alt="" src="https://www.googlefoo.com/xxxx/clk/pagead/conversion/xxxx/?label=HPA&guid=ON&script=0&ord=$$random$$&data=xxx_partner_hotel_id%3Dhotel-name%3Bhct_base_price%3Dtotal%3Bhct_total_price%3Dtotal2%3Bhct_currency_code%3Dcurrency%3Bhct_checkin_date%3Darrival%3Bhct_length_of_stay%3Dnights%3Bhct_date_format%3D%Y-%m-%d%3Bhct_booking_xref%3Dbooking%3Bhct_ver%3D1.0.i"/>);
}
</script>
Two things:
document.write()
expects a string, something between single or double quotes (good thing that the string can contain the other type). As your thing contains double quotes already, I suggest surrounding it with single quotes: document.write('<img height="1"...');
document.write()
overwrites the document, see this example: function test(){ document.write("I am brand new content, everything else is gone."); }
<button onclick="test()">Clicky</button>
So it is not sure that such change (having a proper string) will cover everything you need, you might better use document.createElement("img")
, set its attributes, and put it somewhere in the existing document.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.