Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2016-06-22 12:32:30
- StephMSRTE
- New Member
- Registered: 2016-06-22
- Posts: 2
Google Analytics
Hi there,
Sorry if this has already been discussed but I am trying to use Google Analytics with our website which was built using Textpattern but feedback on the tracking code from Tag Assistant says that the ‘code is found outside of <head> tag’. Please could someone advise as to where I need to move it to as I am unable to work out where it should go as I am unable to see any <head></head> tags.
Thanks
Offline
Re: Google Analytics
For some reason, Google likes you to place it in <head></head> but it is not required.
As an example: https://github.com/textpattern/textpattern-default-theme/blob/master/dist/pages/default.txp
</footer>
<!-- add your own JavaScript here -->
</body>
Offline
#3 2016-06-22 13:58:05
- StephMSRTE
- New Member
- Registered: 2016-06-22
- Posts: 2
Re: Google Analytics
Thank you for your reply. So to clarify it will still work even though the script is not located in <head></head>?
Offline
Re: Google Analytics
StephMSRTE wrote #299935:
Thank you for your reply. So to clarify it will still work even though the script is not located in <head></head>?
I just double-checked. Yes, you do not need to place the code inside <head>.
Offline
Re: Google Analytics
But, StephMSRTE, maybe you would still like to know where to find the Google Analytics code? Or where to find the head
tags in relation to your Textpattern site? Just to know and learn?
Most likely you have a page template that’s been parsed into different forms. It sounds like the opening part of the template is that way, at least. So in the admin-side you could open a given page (e.g, “Articles”, if you have one, but any page might do), and look for the first instance of a tag like this…
<txp:output_form form="FORM_NAME" />
Make note of the “FORM_NAME”, then go to Presentation > Forms and find the form name in the right-side list. Open that and you should see the code for the head
region. That is to say…
<head>
different stuff in here
</head>
Or, sometimes designers will parse templates into tertiary forms (Russian doll nesting, if you will). So maybe you don’t see the head
elements in the form above, but you see another instance of the tag…
<txp:output_form form="head" />
It might be named “head” or something else, but you would then open that form to see if the head
markup is in there, which it probably would be by this point.
Even if not, you see the method now for exploring parsed template code and can probably find it.
Not to make matters more complicated, but there’s also a plugin called smd_where_used, which allows you to search any word or string of words in the entire admin-side to find what admin component (page, form, style, etc) the item might be in. Very handy.
Offline
Pages: 1