SKS
SKS

Reputation: 68

PHP Check whether user clicked on the page

Is there any method to determine whether the user clicked somewhere on the page on PHP? I want to fire a pixel when a user clicked somewhere on the page.

Thanks for your time

Upvotes: 0

Views: 100

Answers (3)

gretarsson
gretarsson

Reputation: 41

To "fire a pixel" when a user clicks somewhere within the page sounds like a task that could easily be done by using JavaScript (JS). You can implement this JS code within the <script>-Tag anywhere within the HTML part of a PHP script.

See

Upvotes: 0

Roberto Braga
Roberto Braga

Reputation: 559

The web page showed in the browser and php are separated world.

Yes php on the server generate the webpage which then is sent to the browser which "execute" it.

If you want to track where user click, you should use some javascript which send the x,y to the server via ajax

To get x,y on mouse click you an use the js in this answer

javascript get x and y coordinates on mouse click

But instead of printing it just send them to the server via javasccript.

Upvotes: 1

Steffen
Steffen

Reputation: 501

PHP is a server-side scripting language. PHP doesn't handle events like mouse or keyboard clicks. For your needs, you should use JavaScript (if your application is meant to work in a browser later on) JavaScript is a client-side scripting language.

Upvotes: 0

Related Questions