简体   繁体   中英

How to send data from static html page to a server?

Is there a way to send data from any static html page to a server like google analytics does. Basically, i want to build an app that counts the element clicks of any html file and store it to a database to be later shown to the user.

Edit: keep in mind that the database i'm sending data to and the html file that i'm requesting data from aren't hosted in the same server.

You can use for that AJAX, Iframe or Tracking Pixel. I think that the best solution would be to use Tracking Pixel.

A tracking pixel (also called 1x1 pixel or pixel tag) is a graphic that is loaded when a user visits a website or opens an email and is used to track certain user activities. A tracking pixel can also be used to acquire statistical data for online marketing, web analytics, or email marketing. This information can then be used for different purposes through log file analysis.

Its mean that you just make a HTTP GET request into your tracking system. For example you can add:

<img src="http://example.com/tracker.php?target=page1&t=12154565612" />

In this way, you can able to pass any data to a tracking server via GET parameters (do not forget to add the time stamp as one of the parameters, it will let you escape the caching).

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM