top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

LightBox click detection in PHP

0 votes
295 views

I need to count the number of times a user activates a LightBox -- how do you do that?

Here's a LightBox Example:

http://www.webbytedd.com/c2/lightbox/

All the javascript is there (jQuery et al).

Ideally, I would like to have a php/javascript combination that would:

  1. Detect when a user clicked the LightBox;
  2. Pass that value to PHP so I can keep count.
posted Jun 14, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
$('.lightbox-image-class').click(function(){
 $.post('ajax.php', {click: true});
});

and do your DB work in ajax.php http://api.jquery.com/jQuery.post/

answer Jun 14, 2013 by anonymous
+1 vote

If you're using Google Analytics, you can use click tracking:

I recently setup click tracking on lightbox open, close and various other modal window bits/pieces for a metered pay wall system.

For example, within the lightbox/modal window "open" method:

// Track this lightbox instance:
window._gaq.push([
 '_trackEvent', // Method.
 'Paymeter Lightbox', // Group.
 'Lightbox OPEN group ' + count_txt, // Append count to "action" text.
 count_txt + ' OPEN event' // Prepend count to "label" text.
]);

The advantage to using a common tool like analytics is that it's got a ton of powerful ways to analyze the data. Not sure the goal of your project, but I thought I would mention.

answer Jun 16, 2013 by anonymous
Similar Questions
0 votes

As per my understanding of interpreted language is scripting(interpreted) language is the language which can executed by CPU straight away without any need of compilation are classified as scripting language

Now if i take example of JavaScript , it does not requires explicit compilation from developer. But browser which interprets actually converts it in to machine instruction which CPU can execute.

So in a way it is also a compiled language though compilation is not required by developer explicitly but browser does it internally. Is n't it ?

Same is the case with PHP.

...