- This topic has 22 replies, 5 voices, and was last updated 9 months ago by
Fernando.
-
AuthorPosts
-
January 18, 2019 at 2:10 am #785305
Marga
Hi, how could I add a javascript text tag (Linkedin Insight tag) just above of </body> tag? I’m using the child theme.
Thank you very much
January 18, 2019 at 4:41 am #785400David
StaffCustomer SupportHi there,
you can use the Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
Create a new Hook add your script, and select the after_footer hook and then assign the display rules for Entire Site ( or selected pages ) for where you want the script to run.
March 4, 2022 at 8:35 am #2142411Margaret
Hello, I am also using a Hook Element to add Javascript.
To run the <script> with minimal effect on pagespeed, where should it be placed?
March 4, 2022 at 8:43 am #2142419David
StaffCustomer SupportHi there,
If possible you would ideally want to add the
<script>
to the Footer via thewp_footer
hook.
This means that script won’t be fired until after the browser has parsed the HTML in the body. So its less likely to tie up the browser that in turn may slow down the rendering of the page.But … it all depends on what the script is doing.
What is the script for?
March 4, 2022 at 8:47 am #2142423Margaret
I am setting up Hubspot Marketing, and they have a
<script>
to label pages under different asset types (standard-page
,landing-page
,blog-post
, etc.) When a lead comes in, Hubspot will use these scripts to attribute the lead to whichever content type the customer was interacting with.https://knowledge.hubspot.com/reports/create-multi-touch-contact-create-attribution-reports
March 4, 2022 at 8:50 am #2142426David
StaffCustomer SupportSounds to me the kind of script that can fire from the
wp_footer
March 4, 2022 at 8:55 am #2142428Margaret
Sounds good, thank you,
Would there be any benefit to adding
async
ordefer
to this<script>
? Or, since it’s already in the footer, would those not have an impact on pagespeed?March 4, 2022 at 8:59 am #2142434David
StaffCustomer SupportIf its in the footer then you should not need to add either of those attributes.
March 4, 2022 at 9:09 am #2142445Margaret
Ok I will not add those attributes. Thanks for your help!
March 4, 2022 at 9:15 am #2142453David
StaffCustomer SupportYou’re welcome
August 29, 2022 at 11:12 am #2327521Jason
Hello, I’m trying to add a script to my site, following these directions: Include this Lightframe API script tag in the body of your page, preferably just before the closing </body> tag: <script type=”text/javascript” src=”https://fareharbor.com/embeds/api/v1/?autolightframe=yes”></script>
I created a hook but wasn’t sure where would be “just before the closing body tag. I tried generate after footer, but that’s not working. Any ideas?
August 29, 2022 at 11:37 am #2327545Ying
StaffCustomer SupportHi Jason,
You can use the
wp_footer
hook, and set the element’s priority to100
.August 29, 2022 at 12:00 pm #2327565Jason
Thank you, Ying. That didn’t work. Adding that script just before the closing tag is supposed to open booking forms on my site. For example, https://charlestonscactivities.com, click any Book Now button and it will open the form while the URL stays the same. On my site, https://milehighactivities.com, that doesn’t happen. The form opens under a different URL.
August 29, 2022 at 12:08 pm #2327579Ying
StaffCustomer SupportThe script is added right before the
</body>
tag:
https://www.screencast.com/t/R3qAV9C3yOIf the script doesn’t work as you expected, it’s better to reach out to the script’s provider ๐
August 29, 2022 at 12:41 pm #2327595Jason
Thank you. I shall do that ๐
-
AuthorPosts
- You must be logged in to reply to this topic.