-1

I am trying to create a pixel tracker using javascript, and have included the necessary parameters in the url and have included this:

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

now, I am unable to understand how to access the parameters on the servlet using java. Could someone help me with this??

sticky bit
  • 36,626
  • 12
  • 31
  • 42
astudent
  • 67
  • 1
  • 7
  • On which servlet? And what's with the empty string "" after 'this:'? Since you're asking about servlets and Java, you could also add corresponding tags. On the other hand, nothing in your question refers to google-analytics or segment-analytics. Why did you tag those? – Roland Weber Jan 29 '19 at 11:54
  • 1
    i have edited the question filling up the blank, and as far as tagging google analytics and segment-analytics is concerned, i wanted to understand how they use pixel tracking to get the url on server side after appending the necessary utm parameters to the url – astudent Jan 29 '19 at 12:18
  • Do you want to track usage of that pixel in Google Analytics, or do you want to send a tracking pixel to create your own tracking system? – Eike Pierstorff Jan 29 '19 at 13:38
  • this is totally unclear, please elaborate on what do you want to get and how to use this? does this have something to parsing get request on serverside or manipulating the DOM? What's the use case of this? – Дмитро Булах Jan 29 '19 at 13:43
  • @EikePierstorff i want to create my own tracking pixel for which i did not know how to access the URL on the server side after attaching the parameters to the URL – astudent Jan 30 '19 at 04:18

1 Answers1

0

I don't have a solid knowledge of java servlet but i believe the same idea will work.

In PHP i would just create a directory with a script that return the content type image/* so for instance

/Document/index.php with the following content

    <?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

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

Again this is for PHP but you should get an idea.

Martin Chuka
  • 109
  • 2
  • 5