8

I want to write a simple javascript tracking code that should be able to push parameters to a remote server.

  • What should I pay attention when writing this code?
  • Is there a difference with the new asynchronous codes around (google analytics style)?
  • Can you provide a very basic example code?

Thank you

Herr
  • 2,725
  • 3
  • 30
  • 36
  • Is it really clever to use jQuery on a tracking code? Although I can see most sites do have jquery by default too – Herr Aug 21 '13 at 06:56

1 Answers1

-2

I would suggest to use jQuery ajax features. Comes with good documentation and examples.

You can send stuff synchronously or asynchronously, via GET, POST etc. See the linked documentation.

  • This should be a comment. – Broxzier Aug 21 '13 at 06:56
  • Is it really clever to use jQuery on a tracking code? Although I can see most sites do have jquery by default too. – Herr Aug 21 '13 at 06:56
  • 1
    @Broxzier "This should be a comment." I am still new to Stackoverflow, so I have to get comfortable with the rules and customs here. Thank you for the advice. – Blasius Secundus Aug 21 '13 at 06:58
  • @Broxzier I agree with Blasius Secundus. We should be more welcoming to new members of our community. – Herr Aug 21 '13 at 07:08
  • @HerrK, Blasius Secundus: I didn't mean offense. At first it was only the first line which is a bit too short for an answer. – Broxzier Aug 21 '13 at 07:17
  • @Broxzier still you are the one with more experience, you should know. http://meta.stackexchange.com/questions/9953/could-we-please-be-a-bit-nicer-to-new-users – Herr Aug 21 '13 at 07:28
  • @HerrK As I said, I didn't mean offense. If you check my history you can see for yourself how many new users I upvoted for useful privileges and welcomed in the comments in their questions. I learned how to use SO [the same way I just told him about comments](http://stackoverflow.com/questions/16545258/is-checked-not-working-while-using-jquery-1-7/16545335#comment23764769_16545335). – Broxzier Aug 21 '13 at 07:36
  • OK no offensive intensions either, next time, be a little bit nicer than. thank you – Herr Aug 21 '13 at 07:43
  • Just to be clear, I did not take it as an offense. I just wanted to say that I was not intended to abuse the system in any way (e. g. intentionally posting a comment an an answer to get more reputation or so) – Blasius Secundus Aug 21 '13 at 08:26
  • 2
    I know this is an old question but I was wanted to say that I don't think using jQuery for a tracking library is a good idea. You are basically adding +100kb payload when you can probably write some ajax functionality in less than 5kb. – Adrian Neatu Jan 04 '16 at 12:37