- This topic has 22 replies, 5 voices, and was last updated 2 years, 6 months ago by
David.
-
AuthorPosts
-
February 1, 2023 at 8:05 am #2517170
Michael
The Google ads support team asked me to install the WPcode light plugin to add some header and footer code. However, the plugin didn’t work. Is this because there might be a conflict between the plugin and generatepress? Is there another way to add code to all headers and footers?
Thanks,
Michael
February 1, 2023 at 9:26 am #2517296Leo
StaffCustomer SupportHi there,
The hook element would be what you are looking for:
https://docs.generatepress.com/article/hooks-element-overview/
https://docs.generatepress.com/article/wp-head/
https://docs.generatepress.com/article/wp_footer/Let me know if this helps 🙂
February 17, 2023 at 5:34 am #2536682Michael
I regret I need more help on this:
(It’s Google code to track Google ads)
I need to add this code in the Global head section of the website above the closing head tag </head> :
https://jsfiddle.net/4Lh7zvkn/
Additionally, paste the code in the Global footer section of the website above the closing body tag </body>:
https://jsfiddle.net/yfzb86gL/3/
Can you give me more specific instructions on how to do this? I haven’t managed to get this from the articles you referenced
Michael
February 17, 2023 at 6:14 am #2536732David
StaffCustomer SupportHi there,
1. go to Appearance > GeneratePress and Enable the Elements Module.
2. in Appearance > Elements -> Add New –> Hook Element.
https://docs.generatepress.com/article/hooks-element-overview/
3. In the Text Area paste in the code that you need to add before the
</head>
tag.4. Set the Hook to:
wp_head
5. Set the Display Rules to
Entire Site
6. Publish that element.
Then repeat the above steps from step 3 for the second code, changing these points:
3. In the Text Area paste in the code that you need to add before the
</body>
tag.4. Set the Hook to:
wp_footer
February 20, 2023 at 2:44 am #2539560Michael
Thanks that looks great,
I’ve added and published, however, a question on reflection:
I didn’t give the hook a name; does that matter,
Michael
February 20, 2023 at 4:52 am #2539702David
StaffCustomer SupportIt doesn’t matter, as WP will just create a no title slug for it.
But you can go back and edit the element, and give it a title for future reference.February 21, 2023 at 2:00 pm #2541771Michael
Unfortunately, https://jsfiddle.net/4Lh7zvkn/ is now viable at the top of every page (for a viewer) and Google says the tags aren’t firing), can you tell me what I’ve done wrong?
Michael
February 21, 2023 at 2:01 pm #2541772Michael
The site is https://nlp-training.org/
February 21, 2023 at 3:21 pm #2541830Ying
StaffCustomer SupportHi Michael,
What’s the exact code you pasted in the hook element?
February 22, 2023 at 1:30 am #2542238Michael
This was the full instructions from Google
(I’ll have a look to see if I’ve made any obvious errors)
Paste the code in the Global head section of the website above the closing head tag </head> :
https://jsfiddle.net/4Lh7zvkn/
(Please click on the above mentioned link to access the code )
Additionally paste the code in the Global footer section of the website above the closing body tag </body>:
https://jsfiddle.net/yfzb86gL/3/
(Please click on the above mentioned link to access the code )
Kindly revert as soon as the codes have been added to the backend of your website so that I can check from my end and see if the codes are firing as expected..
February 22, 2023 at 5:42 am #2542484David
StaffCustomer SupportCan you provide a screenshot of the GP Hook elements, where you added the codes ?
February 22, 2023 at 7:30 am #2542615Michael
https://drive.google.com/file/d/1gB54kj7vFNt73SvOGyqOO79LtpazkIYs/view?usp=sharing
https://drive.google.com/file/d/1BFV0_JkQ_IXQWGDVlOIq7RuuZBAN93_g/view?usp=sharing
https://drive.google.com/file/d/1VsLmfZkOFSLTlKOeZvy46m-vdy3qeKYX/view?usp=sharing
https://drive.google.com/file/d/1rQiJel3QrE0IlELa4nYrnrBGeXs_H864/view?usp=sharing
February 22, 2023 at 9:36 am #2542929David
StaffCustomer SupportAh ok, in the JSFiddle links, you will see the code eg.
<!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-1072711480"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-1072711480'); </script>
That is what needs to be added in the Hook Element, NOT the URL to the jsfiddle.
February 22, 2023 at 10:01 am #2542966Michael
I’m sorry, would you clarify a question?
Does the code you’ve given me go in both the header and footer or are there different codes for each?
Michael
February 22, 2023 at 5:53 pm #2543370Fernando Customer Support
Hi Michael
Try hooking the code here to
wp_head
: https://jsfiddle.net/4Lh7zvkn/Whereas this one, try hooking the code to
wp_body_open
: https://jsfiddle.net/yfzb86gL/3/ -
AuthorPosts
- You must be logged in to reply to this topic.