Please upgrade here. These earlier versions are no longer being updated and have security issues.

How do I add custom JS code to header/footer?

unixherounixhero
edited March 2014 in Vanilla 2.0 - 2.3

Hi

I am installing/enabling an analytics package by Heapanalytics.com . Here are the installation instructions:

"Just paste the following code snippet before your website's closing tag. We'll take care of the rest."

I tried googling around, and I searched the forums... but the answers didn´t make any sense to me.
I want to add a javascript code before the @<;@/@[email protected]>;@ tag.

I am using the default Vanillaforums theme.

Which file should I edit?

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    You can add the js in your default.master.php or you can make a plugin to add it.

    I sugest you download a custom theme and learn how it is put together because to be able to do what you want you need to have a custom theme or create one.

    The default theme is the master theme and should not be edited.

    hgtonight
  • ShadowdareShadowdare π Moderator
    edited March 2014

    You can also create a ThemeHooks file for your theme or use the Pockets plugin to insert HTML code to various areas on your website.

    Add Pages to Vanilla with the Basic Pages app | Publish articles with the Articles app

    vrijvlinderhgtonightbusinessdad
  • businessdadbusinessdad Stealth contributor MVP

    +1 for the Pockets plugin, by far the easiest way to add custom JS.

  • unixherounixhero
    edited March 2014

    Thanks for your suggestions. I am trying to go with the Pockets route, but I am running into problems. The Pockets plugin gives me a 404 when I add a script as a pocket, although html and pure text works fine... I have posted a question to the Pockets-plugin author/community.

    Now I have added the script to the default.master.php file in in the dashboard/views folder.

  • Hi again

    pasting a javascript snippet above the header in default.master.tpl does not work and crashes the forum

    pasting a javascript snippet in Pockets does not work (I was on 2.0 then, and 2.1, new webhost)

    Maybe someone could suggest another way I can add an analytics javascript snippet in a header?

Sign In or Register to comment.