Jump to content

Content type of field to store Google Analytics code


biotech
 Share

Recommended Posts

Hello PW people,

It has been a while...quite a while since I used PW so forgive me for this newbie question. I know that we can easily paste the GA code into the template but I thought to be slick and use field to store the whole JS script. After setting the textarea field to be content type 'none' and saving a page values don't get saved.

Something I need to change on the template processing side? Is this by design so that JS (and CSS and other code snips for that matter) don't get processed?

Thank you.

Link to comment
Share on other sites

 After setting the textarea field to be content type 'none' and saving a page values don't get saved.

Do you mean Content Type: "Unknown" ?

Are you using a regular textarea Inputfield type, or CkEditor. It works fine for me with a regular textarea.

Link to comment
Share on other sites

Hi Adrian,

Yes using "unknown", regular textarea (not using CkEditor) and when I save the page I get the 404 page displayed while the actual URL still sits on site.com/processwire/page/edit/?id=1 being my 'home' page. Using PW 2.6 if it matters.

If I enter just plain text it saves ok but not the GA including <script> tags and all.

Thanks for the time.

Link to comment
Share on other sites

So to clarify, if you don't put any JS code in the texarea then the you see the proper edit page for your homepage? Maybe it's hard to tell now - I am assuming you can no longer edit the homepage at all to even remove the JS code?

Link to comment
Share on other sites

Correct.

If I enter just the plain txt say word "test" all is good, I enter just "<script>" tag itself then on save of the page I am redirected/shown content of my sites 404 page but url remains on http://site.com/processwire/page/edit/?id=1. I can still edit the page just need to reload the page and the old value is still in the field.

This is new just migrated/gone live site. Naturally, placing the GA snip inside the '/site/templates/scripts' or whatever then calling it in template works just doesn't leave it 'manageable' via field.

Thank you.

Link to comment
Share on other sites

Please take a look at this old thread: https://processwire.com/talk/topic/552-i-get-the-404-page-when-editing-home-page/

Firstly try turning on debug mode, but also please check to see if your host is running Apache's modsecurity - seems like it might be the issue. Note in particular the last comment on that thread - maybe you should contact @jlahijani to see if he found a solution as he was also using a <script> tag.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...