Community Forums › Forums › Archived Forums › General Discussion › How to add page-specific script within the body tag
- This topic has 4 replies, 2 voices, and was last updated 7 years, 8 months ago by joycegrace.
-
AuthorPosts
-
July 21, 2016 at 2:16 am #189888joycegraceParticipant
Hi there,
I love that Genesis has the option to input page-specific scripts. This is the field I'm referring to for reference: https://cloudup.com/cYhsL45TGv6
However, Google Adwords conversion tracking tags, as well as Google Tag Manager require their script tags to go into the <body> area of the site. See here: https://support.google.com/adwords/answer/6331314
This is troublesome because from the WP Dashboard, Genesis settings only allow for adding scripts to the header or footer. In Page Specific Scripts area I noticed it adds to the header specifically.
Can someone tell me how this can be worked around? Is there copy-and-page and also 'slightly modify with a page ID' type of code that someone can provide me with?
Buuut, I realize even if I came up with some sort of code to do this in Functions.php but this would get quite tedious over time if we were tracking on multiple pages for different conversions.
Any help would be so much appreciated.
And if anyone knows if the 'Genesis people' read these, or take these into account when releasing updates on their core theme, that would be good to know. Google products are not piddly little no-name tracking systems - these are major developments with the way we track in Google Analytics, Google Re-Targeting products and otherwise nowadays. Yet the Page Specific Script and the Header and Footer Scripts areas of Genesis Settings are not conducive to using these tools in an easy way, for non-coders.
On a semi-related note I have posted asking about how to add the Autotrack.js script to functions.php, but that was a bit of a different request, not needing to be page-specific.
As you can tell I'm not a coder! Please be kind to that!
Find me at Joyce Grace (http://www.joycegrace.ca)
July 21, 2016 at 2:39 am #189890Brad DaltonParticipant1. Use the scripts box on the Edit page or post screen.
2. Otherwise you can use custom code with a custom field and genesis hook which executes after the opening body tag.
genesis_before This hook executes immediately after the opening <body> tag. wp_footer This hook executes immediately before the closing </body> tag. genesis_after This hook executes immediately before the closing </body> tag.
July 21, 2016 at 3:01 am #189891joycegraceParticipantHi Brad,
thanks for the quick response. As I mentioned and explained in detail above, the scripts box doesn't execute in the right place. It goes in the header, whereas I need this code to go in the body tag. That's the reason for this entire post.The other problem is that I'm not a coder, so this is kind of hard for me to figure out. Do you think you could provide some copy-paste code to help me out here?
Could you also help me apply the code to use different scripts on different pages?
Find me at Joyce Grace (http://www.joycegrace.ca)
July 21, 2016 at 4:23 am #189894Brad DaltonParticipantYes, working on a tutorial at the moment titled "3 Ways To Load Single Page or Post Specific Scripts Within the Opening & Closing Body Tags"
Took me over 2 hours to work out, write and test all 3 solutions.
July 21, 2016 at 6:41 pm #189978joycegraceParticipantA friend also gave me this: https://www.godaddy.com/garage/webpro/wordpress/3-ways-to-insert-javascript-into-wordpress-pages-or-posts/
I'll have to take a look at options.
If anyone else has possible ideas or solutions please do pass them on.
Find me at Joyce Grace (http://www.joycegrace.ca)
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.