- This topic has 7 replies, 2 voices, and was last updated 4 years, 1 month ago by Tom.
-
AuthorPosts
-
March 10, 2020 at 1:30 pm #1191274Joe
Hi there, I’m having a very weird issue:
– I added the crazyegg tracking script to my staging website by going to GeneratePress > Elements and adding it as a hook for the header for all pages, exactly the same way I added the Google Analytics tracking code.
– When I published it I see it on my chrome browser without any issue by going to Inspect > then searching for the tracking script. It’s on line 157.
– When I tried to sync my staging to production I could not see the new script on production
– So I wrote to Cloudways, my hosting provider, asking them why staging wasn’t syncing to production
– Turns out they could not see the new code on staging NOR production, it was completely non-existent for them– While I can indeed see the new piece of code on Chrome, when I checked on Firefox it’s not there either, so for some reason, which is just bizarre
– I cleared all of my caches: regular, Cloudflare, WP Rocket, etc… and it did not seem to help the problem
– Cloudways told me to contact my theme provider to see if you can help me figure this out… any idea what the problem could be?
Staging site: https://wordpress-373625-1192257.cloudwaysapps.com
Live site: https://ir.statecraftsims.com/March 10, 2020 at 4:49 pm #1191378TomLead DeveloperLead DeveloperHi there,
Elements are just a form of custom post type. If you go into “Appearance > Elements” in your staging or live site, do you see the Element you created?
If so, are the Display Rules the same? Perhaps something about the sync processed messed with them?
Let me know 🙂
March 11, 2020 at 3:48 pm #1192370JoeOk, I still am having this problem but I actually think maybe it’s not a staging sync deal, it’s that my code isn’t fully appearing.
So I can see the “hook” in both the wordpress admins and it looks EXACTLY the same. I’ve published it, cleared the cache, etc. In Chrome if I do “inspect” for either ULR I can search for crazyegg and see the script on line 157. In Firefox the script doesn’t show up for either one. If I check the code installation via Crazyegg it says the code isn’t installed on the site.
I did this hook exactly the same way as the google analytics hook so it’s very odd to me that I’m having this random problem.
I did a hook, and added the code:
<script type=”text/javascript” src=”//script.crazyegg.com/pages/scripts/0085/8323.js” async=”async”></script>set it to wp_head and location “Entire Site”
In the admin it says it’s published with visibility publicMarch 12, 2020 at 8:33 am #1193055TomLead DeveloperLead DeveloperSome servers won’t allow for
<script>
elements to be saved to a database for security reasons. For testing purposes, what if you change the content to “Hi!”? Does the text show up in your source?March 12, 2020 at 12:27 pm #1193222JoeHi! Yes, if I change my text to just say “hi” it does indeed show up on all browsers in the code.
How do I deal with this? I’d really love to be able to use crazyegg right now and get that script added. What do you suggest?
Thanks so much for the help here!!
March 12, 2020 at 6:57 pm #1193382TomLead DeveloperLead DeveloperSo that means your server is likely blocking the
<script>
element from being added to the database. It’s usually a mod_security setting.They should be able to fix the issue for you quite easily.
Otherwise, you’ll need to use a function:
add_action( 'wp_head', function() { ?> Your script in here. <?php } );
March 18, 2020 at 10:31 am #1198726JoeHi Tom, I finally figured this out thank GOODNESS! It was an issue with WP Rocket and the Crazyegg script. I had to add the script in WP Rocket settings -> File Optimization -> scroll to javascript files section -> in Excluded JavaScript Files input box add “script.crazyegg.com”
It’s finally working now.
Thank you so much for trying to help me!
March 18, 2020 at 4:08 pm #1198938TomLead DeveloperLead DeveloperGlad you got it working! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.