Add Google Analytics code for pop up lightbox

Hello X Team,

I’m having a pop up lightbox on my site but it doesn’t show up at my Google Analytics.
Do you know how I can change this?

Thank you.

Hi @smart_x,

Please try adding this custom JS under Theme Options > JS:

jQuery(document).ready(function($) {
	$("#menu-item-3039 a").on('click touchend', function(event) {
		ga('send', 'event', 'Button', 'Click', 'Open Lightbox');

For more information, please take a look at these article:

Hope it helps :slight_smile:

Hi @thai,

If I go to Theme Options then I only have a JS option at the left sidebar. When I click on this one it opens GLOBAL JS.
I added the code into the GLOBAL JS. Then I tested it with my Goolge Analytics open. It doesn’t show up.

It will show witch page i’m visiting but when I click the lightbox Google Analytics will keep showing the page where from I clicked it.


Can you provide us your wordpress admin login in Secure Note so we can take a closer look.


Hello @paul.r

Thank you for your reply.

Hi @smart_x,

It seems you’re using the MonsterInsights plugin to connect the Google Analytics to your website. They’re using the different function so the ga('send', 'event', 'Button', 'Click', 'Open Lightbox'); function is not working.

Regretfully, we cannot provide support for third party plugins or scripts as our support policy in the sidebar states due to the fact that there is simply no way to account for all of the potential variables at play when using another developer’s plugin or script. In this case, you should contact to the plugin author to help you with this.


Hello @thai,

Thank you for your answer.

So if I disable the MonsterInsights plugin then it should work?
In my Google Analytics I can see under Behaviour > Events > Overview > :

Event Category
Event Action
Event Label

I see some undefined names there. IS it possible that the Lightbox doesn’t have a clear (recognizable) name/tag?

Hi @smart_x,

You don’t have to disable it, you have to utilize its feature since it’s the one installed and used for google analytics. I recommend contacting the plugin author for more options about those features.

Events are triggered by javascript and not just tags, and I can’t really tell how it’s implemented by the plugin.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.