Hi,

Hotjar script is not adding in the head of HTML. I have debug it and found that function "hotjar_preprocess_page" is not executing in the default or frontend theme but it's working in administrator theme.

Is it right to use hook_preprocess_page hook to add JS?

Thanks,
Sanjay

Comments

sanjay.soni created an issue. See original summary.

tikaszvince’s picture

Hi,

I think hook_preprocess_pageas right to add JS to page as any other. Before we try to find other point for adding tracking code, please check these:

Is tracking code placed in <head> when you view frontpage with an anonymous user?
Please check your settings on admin/config/system/hotjar page!
Does your site has a Hotjar ID?
Are tracking settings allow trackink for anonymous user?

thanks

sanjay.soni’s picture

StatusFileSize
new490 bytes

Tracking code is not adding because we are using panels_everywhere module and "hook_preprocess_page" is not compatible with panels_everywhere so this module is not allowing to add the script.

Please find below references.

https://www.drupal.org/node/2462541

https://www.drupal.org/node/1190894

introducing a patch so that hotjar module can be compatible with panel_everywhere module.

Thanks

sanjay.soni’s picture

Any update on this?

tikaszvince’s picture

Status: Active » Needs review
StatusFileSize
new918 bytes

I just don't like the idea to use hook_preprocess_html because at that point scripts already added. Hotjar doesn't need to add at the end of the page rendering process.

Maybe the hook_page_build would be the best choice. Please check the patch I attached with panels_everywhere.

  • tikaszvince committed 9650688 on 7.x-1.x
    Issue #2768187 by sanjay.soni, tikaszvince: Make compatible with...
tikaszvince’s picture

Status: Needs review » Fixed
tikaszvince’s picture

Status: Fixed » Closed (fixed)
aarontocenter’s picture

The issue that I had was after install, the configuration page at /admin/config/system/hotjar would reset back to the System Module list, this may be do to the admin theme, but the way I fixed it was to enable the Admin Hotjar in Permissions for Anonymous user roles.

Once the single permission was enabled, tested as accessible via anonymous, then disabled the permission for anonymous, saved, and I was able to access the admin page for Hotjar through the Admin Theme menu just fine. Hope this helps.