Google Analytics - homepage

I want to implement stats Google Analitycs to may OJS homepage. Not to journals (I know that we have Google Analitycs Plugin), but to homepage.
Where I must add tracking code? In what file?

What version of OJS are you running? Recent versions should do this via the Common footer:

My version is 2.4.5

Look at

In plugins/generic/googleAnalytics/ I have the same data.

I add tracking code in templates/common/footer.tpl:


  • templates/common/footer.tpl
  • Copyright (c) 2013-2014 Simon Fraser University Library
  • Copyright (c) 2003-2014 John Willinsky
  • Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  • Common site footer.

{if $pageFooter==’’}
{if $currentJournal && $currentJournal->getSetting(‘onlineIssn’)}
{assign var=issn value=$currentJournal->getSetting(‘onlineIssn’)}
{elseif $currentJournal && $currentJournal->getSetting(‘printIssn’)}
{assign var=issn value=$currentJournal->getSetting(‘printIssn’)}
{if $issn}
{translate|assign:“issnText” key=“journal.issn”}
{assign var=pageFooter value="$issnText: $issn"}

{include file=“core:common/footer.tpl”}


and also in templates/index/site.tpl


  • templates/index/site.tpl
  • Copyright (c) 2013-2014 Simon Fraser University Library
  • Copyright (c) 2003-2014 John Willinsky
  • Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  • Site index.

{if $siteTitle}
{assign var=“pageTitleTranslated” value=$siteTitle}
{include file=“common/header1.tpl”}

{if $intro}


{if $useAlphalist}

Czasopisma alfabetycznie: {foreach from=$alphaList item=letter}<a href="{url searchInitial=$letter sort=“title”}">{if $letter == $searchInitial}{$letter|escape}{else}{$letter|escape}{/if} {/foreach}{if $searchInitial==’’}{translate key=“common.all”}{else}{translate key=“common.all”}{/if}

{assign var=“idx” value=1}
{iterate from=journals item=journal}

{if $site->getSetting(‘showThumbnail’)}
{assign var=“displayJournalThumbnail” value=$journal->getLocalizedSetting(‘journalThumbnail’)}

{if $displayJournalThumbnail && is_array($displayJournalThumbnail)}
{assign var=“altText” value=$journal->getLocalizedSetting(‘journalThumbnailAltText’)}


{if $site->getSetting(‘showTitle’)}


{if $site->getSetting(‘showDescription’)}
{if $journal->getLocalizedDescription()}



{translate key=“site.journalView”} | <a href="{url journal=$journal->getPath() page=“issue” op=“current”}" class=“action”>{translate key=“site.journalCurrent”} | <a href="{url journal=$journal->getPath() page=“user” op=“register”}" class=“action”>{translate key=“site.journalRegister”}

{if ($idx % 3) === 0}

{assign var=“idx” value=$idx+1}
{if $journals->wasEmpty()}
{translate key=“site.noJournals”}

{page_info iterator=$journals}

{page_links anchor=“journals” name=“journals” iterator=$journals}

{include file=“common/footer.tpl”}

but 0 results…

Hmmm… I think this is a bug. The Google Analytics plugin operates with journal specific context, so there is no way to save a configuration for the plugin at the sitewide level.

Where did you manually add the code in templates/common/footer.tpl? You’ll need to watch out for the conditional that checks for an existing $pageFooter. That could mask your addition.

I dont know... I want add analitycs code (Google Analitycs)but not to journal sed to homepage ( Ive a tracking code and enter to common/footer.tpl…and nothing.
Can you help me?

There are several different footers to consider here:

  • templates/article/footer.tpl - user for article display
  • templates/common/footer.tpl - used for most other pages, calls
  • lib/pkp/templates/common/footer.tpl - generally sitewide, except for article pages

Additionally, the Google Analytics plugin hooks the article display intersticials, and provides support for Google Scholar account for authors. If you disable the plugin in favor of adding the the code manually, be aware of that.

If you provide the example of where you’ve tried adding the code, we can probably identify why it is not displaying.

Having some interest in experimenting with plugins which sometimes operate in a Site context, and sometimes operate in a Journal context, I have a proposed modification to the Google Analytics plugin to do this.

Dear @ctgraham and others

In version still I can not do any settings in the site-settings ( so that GA can be collected for the non-jounral-specific webpages.


The best /Edvin

This is a longstanding bug in 3.x. We’ve made some progress in addressing it, but also further locked in the broken functionality as well.

The fix for 2.x was a fairly easy workaround, but for 3.x it is actually surprisingly complex. I’ll connect with the other core developers to try to decide on a strategy.