Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 08:15:16 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155528 Posts in 21713 Topics by 7737 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: add code to wb pages?  (Read 808 times)
sebigbos

Offline Offline

Posts: 56


WWW
« on: July 24, 2009, 11:13:33 AM »

Hi,

for some web analytics tools I needed to add a tracking code to the wb-pages. I did this just adding the code in the php-files in the pages directory and the code then appeared in View Source and all fine. After updating wb from 2.6.7. to 2.7. the code doesn´t appear anymore. Any idea which change in wb structure made this and how to change that?
thanks,
sebigbos
Logged
WebBird
Guest
« Reply #1 on: July 24, 2009, 11:22:18 AM »

What kind of code do you mean? PHP? You can use a Code-Section or a Droplet for this. It will be left untouched on upgrade.
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6975


WWW
« Reply #2 on: July 24, 2009, 11:44:03 AM »

Your issue is that you should place this code into the index.php of the template. This way, if your template is not one of the standard templates and has it's own name and everything, it will not be overwritten when upgrading.

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

sebigbos

Offline Offline

Posts: 56


WWW
« Reply #3 on: July 24, 2009, 12:02:28 PM »

@webBird: php code, it´s a tracking code to count visits.

@klaus: the code submits statistics about the visits of every site, so I think I need the code be related to the different sites

I think the update did not change the pages-related files in the pages directory but the way this files were executed...
Logged
WebBird
Guest
« Reply #4 on: July 24, 2009, 12:16:15 PM »

I'm sure there is a way of including the code into the template AND tracking the current page. (Using the PAGE_ID or page_title or something.)

Maybe you'd like to post the code here, so we can help.
Logged
mr-fan

Offline Offline

Posts: 1556


WWW
« Reply #5 on: July 24, 2009, 12:16:53 PM »

hi sebigbos,

Quote
so I think I need the code be related to the different sites

...it'S a dynamik website....created by a template.....if your put a code/html/ja stuff in your template it will be output in EVERY page... wink google analytic chcounter and all the other tracking counters must simple paste in the index.php of your used template to get it working properly!

the index.php is == base for every page you create
the php stuff in this index.php is dynamic changed for every page like contentblocks or menus....

regards martin
Logged

 
sebigbos

Offline Offline

Posts: 56


WWW
« Reply #6 on: July 24, 2009, 04:21:55 PM »

o.k., first, I love this forum, there always guys who like to help and do this at once....!

I don´t use google analytics or other, I use PIWIK. And this software, which is very good in ease of use and features and all, needs to place the code in all the pages (at least I think so and it worked until the update).

In old WB (2.6.7) including the code in the pages php-files makes the code appear in the source code of the page and the tracker (PIWIK) works. My idea is to get WB 2.7. to do this also. But I would accept any other solution of course. Here is the code of my home-site including the tracking code:

<?php
$page_id = 9;
require("../config.php");
require(WB_PATH."/index.php");
?>


<!-- Piwik -->
<a href="http://piwik.org" title="Web 2.0 analytics" onclick="window.open(this.href);return(false);">
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.p rotocol) ? "https://www.musikunterricht-in-rosenheim.de/piwik/" : "http://www.musikunterricht-in-rosenheim.de/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
piwik_action_name = '';
piwik_idsite = 1;
piwik_url = pkBaseURL + "piwik.php";
piwik_log(piwik_action_name, piwik_idsite, piwik_url);
</script>
<object><noscript><p>Web 2.0 analytics <img src="http://www.musikunterricht-in-rosenheim.de/piwik/piwik.php?idsite=1" style="border:0" alt=""/></p></noscript></object></a>
<!-- End Piwik Tag -->
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6975


WWW
« Reply #7 on: July 24, 2009, 06:39:31 PM »

Even if I repeat myself ... add this to your Template and not to the pages itself ... This way it gets added to every page WebsiteBaker serves!

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

WebBird
Guest
« Reply #8 on: July 24, 2009, 07:05:04 PM »

Hm... I don't see where $page_id is used in the PIWIK-Code... But as Klaus said, just add the Piwik-Part to your index.php. (Of the template you use.)

If you need the var $page_id, just include this anywhere before PIWIK:

Code:
<?php
    $page_id 
PAGE_ID;
?>


Edit: If piwik_idsite is the page id, try this:

Code:
<!-- Piwik -->
<a href="http://piwik.org" title="Web 2.0 analytics" onclick="window.open(this.href);return(false);">
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.musikunterricht-in-rosenheim.de/piwik/" : "http://www.musikunterricht-in-rosenheim.de/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
piwik_action_name = '';
piwik_idsite = <?php echo PAGE_ID ?>;
piwik_url = pkBaseURL + "piwik.php";
piwik_log(piwik_action_name, piwik_idsite, piwik_url);
</script>
<object><noscript><p>Web 2.0 analytics <img src="http://www.musikunterricht-in-rosenheim.de/piwik/piwik.php?idsite=<?php echo PAGE_ID ?>" style="border:0" alt=""/></p></noscript></object></a>
<!-- End Piwik Tag -->
« Last Edit: July 24, 2009, 07:06:41 PM by WebBird » Logged
sebigbos

Offline Offline

Posts: 56


WWW
« Reply #9 on: July 25, 2009, 11:39:44 AM »

o.k., great, I added the tag (plus <?php $page_id = PAGE_ID; ?>) to the index.php and now the code is included in the source code of all pages. PIWIK is counting visits of every page, if I go directly to the URL.

It is not counting visits which are directed from an extern link or a search engine, like before with wb 2.6.7. and the code written in every page´s file. Maybe this is a question to be presented in the PIWIK-forum, but if you have any idea, welcome....

thanks so far,
sebigbos
Logged
sebigbos

Offline Offline

Posts: 56


WWW
« Reply #10 on: July 25, 2009, 01:53:26 PM »

forget my last post....it´s all working great now, problem solved.....thanks.
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!