Probably stupid <noscript> question

Status
Not open for further replies.

Walshicus

Ars Tribunus Militum
2,597
Hi all,

I've been asked to place some Google remarketing scripts on my company's website through our container script, and something's been bugging me about it. The script below (which I'm sure a lot of you have seen before) has a <noscript> component to it which I tend to strip out when implementing through our container script. I'd assumed that there was no scenario where the visitor would render the <noscript> since it was being placed on the page through javascript, and I'd assumed that the tracking image referenced in it wouldn't even be loaded.

Our Google contacts have requested the <noscript> is put back in, and while that's not a problem it *has* been niggling on me and my limited javascript knowledge as to why it would be needed.

I'm sure this is just a lack of knowledge in this area on my part, but I'd love if someone could explain to a layman!




Code:
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = [NUMBERS];
var google_conversion_label = "[STUFF]";
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/[NUMBERS]/?value=0&amp;label=[STUFF]&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
 

technophile

Ars Legatus Legionis
23,768
[url=http:/civis/viewtopic.php?p=25585369#p25585369:l5se0fog said:
Mile Zero[/url]":l5se0fog]The noscript tag isn't inside the script tag, so it doesn't rely on JavaScript. It triggers a manual tracking pixel load for people who don't have JavaScript enabled.
Except that Walshicus notes in his original post that, "[the code below] was being placed on the page through javascript". So the <noscript> tag wouldn't ever be placed if JS is not enabled.

Adding a <noscript> tag via Javascript is the height of uselessness, in other words. :p



As for the original question, my guess is one of two things (possibly both):

1) The code is intended to be added in a static (or at least not-Javascript) method, in which case the <noscript> tag would function correctly, and your Google contacts don't know/understand that you're adding the code via JS, or
2) They're simply adhering to a tech-support script which requires the code snippet be placed exactly as in the docs in order to minimize potentially important differences when troubleshooting problems.


To be fair, I don't know why you'd add the code via JS; you may as well just put it in statically. If you're doing a single-page application or something then you can use the AdSense API (_trackPageview) to track page views that don't involve a normal HTTP transition.
 

technophile

Ars Legatus Legionis
23,768
[url=http:/civis/viewtopic.php?p=25607507#p25607507:20swrgyj said:
jxl[/url]":20swrgyj]Exactly what "being placed on the page through javascript" actually means is anyone's guess; it's not terribly common (putting it charitably) for .js files to include <script> tags.
I'm assuming he's using document.write or whatever equivalent. I know a number of the "example" scripts for AdSense, the Facebook API, etc have you use document.write to create script tags etc for no real apparent reason.
 

Mile Zero

Ars Praetorian
578
Subscriptor++
[url=http:/civis/viewtopic.php?p=25607255#p25607255:kpyguktm said:
technophile[/url]":kpyguktm]
[url=http:/civis/viewtopic.php?p=25585369#p25585369:kpyguktm said:
Mile Zero[/url]":kpyguktm]The noscript tag isn't inside the script tag, so it doesn't rely on JavaScript. It triggers a manual tracking pixel load for people who don't have JavaScript enabled.
Except that Walshicus notes in his original post that, "[the code below] was being placed on the page through javascript". So the <noscript> tag wouldn't ever be placed if JS is not enabled.

Good catch. I'm guessing you're right with #1. I'm also a bit confused as to why someone would use JS to put this script on the page. Everywhere else I've ever seen it, it's embedded right in the document.
 
Status
Not open for further replies.