Tracking Site Hits
-
I was given this 'tracking code' to stick in a website the other day (account #s, domains & code comments removed).
wtfs include:
-
using a client-generated "random" number (to prevent caching, maybe?)
-
"random" number converted to string, string multiplied back into a number, then coerced back into a string, for no apparent purpose
-
Capitalizing "HTTP" - Case does not matter, but...
-
using document.write()
-
not using google analytics
-
what year is this?
(edit: is there a trick to having an un(ordered)? list directly above a code block without some text below it ? Fuck.)
<script type='text/javascript'> var ebRand = Math.random()+''; ebRand = ebRand * 1000000; //<![CDATA[ document.write('<scr'+'ipt src="HTTP://subdomain.domain.com/Serving/ActivityServer.bs?cn=as&ActivityID=XXXXXX&rnd=' + ebRand + '"></scr' + 'ipt>'); //]]> </script> <noscript> <img width="1" height="1" style="border:0" src="HTTP://subdomain.domain.com/Serving/ActivityServer.bs?cn=as&ActivityID=XXXXXX&ns=1"/> </noscript>
edit by a to add code block and formatting
-
-
(edit: is there a trick to having an un(ordered)? list directly above a code block without some text below it ? Fuck.)
- Did
- You
- Try
A blank line between the list and the code block?
-
Yessir, I tried 3 blank lines. Maybe I was doing something crazy.
-
Looking at your original raw code, you weren't marking the code block as such. The forum software was just flagging it seperately, probably because of the script tags. To learn how to properly flag a code block, please read through the FAQ topics (not the one you can get to through the menu). I've corrected it in your post for you this time.
-
But Google Analytics is NIH™!
-
I typed some text. Then I copied/pasted the js code block. Then I used the discourse wysiwyg options to mark the javascript as code. Then I attempted to put dashes in front of the list items to make it a list.
What did I not do correctly?
-
True, Google probably has a 27,000 server farm to generate REALLY random numbers.
-
What did I not do correctly?
I used the discourse
Answer is self-evident
-
the discourse is bad. the discourse must learn.
-
Why do you even need a random number. Just do an AJAX POST request for the actual tag; I don't know why you'd want your analytics JS to not be cached.
-
It's obviously version
Math.random()
-
Clearly now that you learned how to handle Discourse, the next step of action is to redirect the page-tracker to Discourse so it creates a topic for every user that is being handled.
Once that is done you can use the handly SQL-tools to find out how many visits exist and who of those is trustlevel2!Filed Under: After being a BugTracker and a Forum, Discourse can be used for pretty much everything!
-
Discomorphism!
-
What did I not do correctly?
Of the 300 methods of marking a code block, you used the wrong one ;)
(You used the 4-space indent - the
correctless incorrect way is to use the 3-backtick code-fence - the latter doesn't involve messing around with the UI buttons, messing around with your code and - as we've now seen - messing around with lists preceding the block.)Edit: I know the general FAQ category was linked to earlier by @abarker, but this is the particular topic relevant here.
-
Of the 300 methods of marking a code block, you used the wrong one
That sounds about right - story of my life :-)
-
Isn't the 4-spaces thing doubled in the case of being inside a list element? Why would it need to be doubled after a list?
-
Yes, and no idea.
-
"Our 300 methods of marking code are too stable, let's add another one that involves whitespace."
-
@discobutt
-
Originally posted by @Lorne_Kates:
-
Ahh, my company hates Canada.
Reason: High Security Risk: Not allowed to browse the NONE category
-
High Security Risk: contains animation of leaky car battery
-
"Our 300 methods of marking code are too stable, let's add another one that involves whitespace."
Discourse or Python? :)
-
-
Can't be any worse than using it to track bugs and feature requests.
-
'<scr'+'ipt
Is there a legitimate reason to do this apart from getting around a naïve filter?
-
If you have this HTML:
<script> document.write('</script>'); </script>
the script ends after the first
'
because HTML doesn't have its own JavaScript parser. It just passes the contents of the tag to the JavaScript parser.Edit: but if you use
<![CDATA[ ]]>
and you do that then you're just a moron.
-
I suppose that makes sense, although I admit ignorance was bliss. Literals not being treated as such seems like a WTF, even if it's outside HTML's purview.
-
It'd be the same as this not doing what the author expected:
var paragraph = "I asked, "How are you doing?"";
Languages generally don't know other languages' syntax. When the HTML parser sees the
</script>
, it has no idea it's in a string literal.
-
-
yeah. if only BDFL Guido had stepped in four methods earlier....