Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7527147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:02:36+00:00 2026-05-30T04:02:36+00:00

My script tracks clicks on a client’s page and uploads this to my server(let’s

  • 0

My script tracks clicks on a client’s page and uploads this to my server(let’s call it .http://fancyclickserver23.net)

Now I want the client to put a script on his site and this script will tag the clicks on the page and send the data to .http://fancyclickserver23.net on page leave or maybe even from time to time.

I can’t use Ajax because of cross browser restrictions, ofcourse. So how do I do this?
I’ll give a little hypothetical code to help you understand.
I have a closure tracker which is loaded when the user puts

<script src="http://fancyclickserver23.net/loadtracker.php?client_id=2332"></script>

The code loads the closure tracker=function(){….};
The user needs to create an object of tracker

<script>
track=new tracker();
track.init();
</script>

track.init() basically binds a function that gets the Xpath of the element and stores it in track.clicks . Now i need to have a function track.send() which will send the clicks array as json(I know how to convert it to json) and send it on page close.

How do I do this. Also I have seen some sites use something like:

 document.write("<sc"+"ript"+" src='https://fancyclickserver23.net/loadtracker.php?client_id=2332'"+"></scr"+"ipt>";

Why do this instead of a direct script tag? And why not put it in one string if we must use document.write() at all.

So the two questions are:

  1. How do I send the data asyncronously(or otherwise) on page load?
  2. What does the above code do?
  3. I’ve seen Google analytics and Facebook do this, they don’t seem to have any problems. Facebook infact renders the dialog box on screen. How?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:02:38+00:00Added an answer on May 30, 2026 at 4:02 am

    Despite the cross-domain security restrictions, you can still use AJAX (XHR) to some extent.

    Browser can not trash a cross-domain request just like that. It has to see what the server thinks of it first. It does this by sending the actual request over to the server and receiving the instructions along with the response in HTTP headers. If the Access-Control-Allow-Origin header doesn’t arrive or doesn’t match the origin domain, browser trashes the response and throws out a security warning in the console.

    From my personal experience, Access-Control-Allow-Origin header or not, when site aaa.com sends an AJAX request to site bbb.com the one-way delivery of the data payload to the server happens anyway. It’s just a monologue, but what more do one need for collection of data, right? 😉

    I, for example, utilize the one-way technique for something similar to yours – I collect JSON reports of unit tests results of my open-source project here. You can spot the security warning in the console, but at that time the report is already stored safely on the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking to tweak this script: http://css-tricks.com/examples/InfoGrid/ I've added an image within each dt, I'd
I have a script which tracks visits & referers to a website. I send
Script: http://keith-wood.name/countdown.htm Daily json response: items: { fajr: '5:23 am', sharooq: '7:23 am', dhur:
The script to setup up the SQL Server database for Elmah has a warning
I have a modal dialog in main page, then I add jPlayer to this
I am trying to customize this script so that instead of a user's recent
I'm writing a small script to capture link clicks and save the link's URL
Say I have a URL: <a href=hello.html id=4298>hello</a> When someone clicks this link, I
The site in question is http://getstefan.com Its a single page portfolio site and I
I have three leaves in my navigation bar on this page . Each leaf

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.