piwik tracking for multilingual site

vincent3569 Member, Translator
hi

I use this code to track my visitors with piwik:

`


var _paq = _paq || [];
_paq.push(['setDocumentTitle', "<?php
if (($_zp_gallery_page == 'index.php') && ($isHomePage)) {echo gettext('Home'); }
if (($_zp_gallery_page == 'index.php') && (!$isHomePage)) {echo gettext('Gallery'); }
if ($_zp_gallery_page == '404.php') {echo gettext('Object not found'); }
if ($_zp_gallery_page == 'album.php') {echo getBareAlbumTitle(); }
if ($_zp_gallery_page == 'archive.php') {echo gettext('Archive View'); }
if ($_zp_gallery_page == 'contact.php') {echo gettext('Contact'); }
if ($_zp_gallery_page == 'favorites.php') {echo gettext('Favorites'); }
if ($_zp_gallery_page == 'gallery.php') {echo gettext('Gallery'); }
if ($_zp_gallery_page == 'image.php') {echo getBareAlbumTitle() . '|' . getBareImageTitle(); }
if (($_zp_gallery_page == 'news.php') && (!is_NewsArticle())) {echo gettext('News'); }
if (($_zp_gallery_page == 'news.php') && (is_NewsArticle())) {echo '|' . getBareNewsTitle(); }
if ($_zp_gallery_page == 'pages.php') {echo getBarePageTitle(); }
if ($_zp_gallery_page == 'password.php') {echo gettext('Password Required...'); }
if ($_zp_gallery_page == 'register.php') {echo gettext('Register'); }
if ($_zp_gallery_page == 'search.php') {echo gettext('Search'); }
?>"]);
_paq.push(['enableLinkTracking']);
_paq.push(['setDownloadExtensions', "zip"]);
_paq.push(['trackPageView']);
(function() {
var u = (("https:" == document.location.protocol) ? "https" : "http") + "://piwik.vincentbourganel.fr/";
_paq.push(['setTrackerUrl', u + 'piwik.php']);
_paq.push(['setSiteId', 3]);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; g.type = 'text/javascript';
g.defer = true; g.async = true; g.src = u + 'piwik.js'; s.parentNode.insertBefore(g, s);
})();



`
after some tests, I only want to track non translated title of all page names.
For all items (except albums, images, news and pages), it's easy to do: I have to use a 'static' title, instead of translated one with gettext (Accueil, Galerie, Archives,...).

But I have a trouble with albums, images, news and pages:
`getBareAlbumTitle()`, `getBareImageTitle()`, `getBareNewsTitle()` and `getBarePageTitle()` return translated value of the title.

How force the display title of albums, images, news and pages in only one language (french) to only track one title in piwik (I have other informations for tracking the country of my visitor)?

Comments

  • acrylian Administrator, Developer
    You would have to use the class method like `$obj->getTitle('')` to get a specific one.
  • vincent3569 Member, Translator
    thanks acrylian
    a little more complicated than `getBareAlbumTitle()` (and other), but it works fine.
  • acrylian Administrator, Developer
    Yes, this hte hte "base" way of the object model behind everything. The "bare" function mean only that the display is "sanitized" but it is the current language always.
Sign In or Register to comment.