Google Analytics - homepage


#1

Hi,
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?
Thanks
Peter


#2

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


#3

My version is 2.4.5

Look at http://pressto.amu.edu.pl

In plugins/generic/googleAnalytics/GoogleAnalyticsPlugin.inc.php#L45 I have the same data.

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

{**

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

}
{strip}
{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}
{if $issn}
{translate|assign:“issnText” key=“journal.issn”}
{assign var=pageFooter value="$issnText: $issn"}
{/if}

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

{/strip}

and also in templates/index/site.tpl

{**

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

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


{if $intro}

{$intro|nl2br}
{/if}

{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}


{/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}

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

{$journal->getLocalizedTitle()|escape}


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

{$journal->getLocalizedDescription()|nl2br}


{/if}
{/if}

{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}
 

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

{page_info iterator=$journals}

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

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

but 0 results…


#4

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.


#5

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


#6

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.


#7

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.


#8

Dear @ctgraham and others

In version 3.1.1.4 still I can not do any settings in the site-settings (www.mysite.com/index/admin/settings) so that GA can be collected for the non-jounral-specific webpages.

The best /Edvin


#9

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.