简体   繁体   English

像素跟踪:检索通过 url 发送的参数 via<img src=""/> 在服务器端

[英]pixel tracking : retrieving the parameters sent through url via <img src=""/> on server side

I am trying to create a pixel tracker using javascript, and have included the necessary parameters in the url and have included this:我正在尝试使用 javascript 创建一个像素跟踪器,并且在 url 中包含了必要的参数并包含了这个:

img src="/Documents/myimg.gif?utm_source="myfile"

now, I am unable to understand how to access the parameters on the servlet using java.现在,我无法理解如何使用 java 访问 servlet 上的参数。 Could someone help me with this??有人可以帮我解决这个问题吗??

I don't have a solid knowledge of java servlet but i believe the same idea will work.我对 java servlet 没有扎实的知识,但我相信同样的想法会奏效。

In PHP i would just create a directory with a script that return the content type image/* so for instance在 PHP 中,我只需要创建一个包含返回内容类型 image/* 的脚本的目录,例如

/Document/index.php with the following content /Document/index.php包含以下内容

    <?php 

    $getVar=$_GET;

    // do the necessary with the get vars
    header('Content-Type:image/jpg');// you can adjust the content type accordingly

    /* this is the image url. you can use 
    .htaccess and get this as the last parameter of the url just like in your question */
    readfile('myimg.gif');

To make the url just like what you have currently - .htaccess will help to rewrite the url to look pretty much like anything, even take multiple images/actions with switch statement or if on the back-end为了使URL就像你有什么现在-的.htaccess将有助于重写URL看起来非常像任何东西,甚至随身携带多张图片/动作switch语句或if在后端

<img src="/Documents/myimg.gif?utm_source="myfile"/>

Again this is for PHP but you should get an idea.这同样适用于 PHP,但您应该有一个想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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