That's awesome, Nick. I can tell, not only from this thread but from all over the Hotaru forums, that you must be a great teacher.
Okay, so from everything I have so far, this is the code I'm looking at adding to the header:
Code:
if (!isset($h->vars['analytics'])) {
if ($h->post->author);
$h->vars['analytics'] = $profile ['analytics'];
$profile['analytics'] = str_replace("\"", "'", $profile['analytics']);
}
echo {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?php echo $profile['analytics']; ?>']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>";
}?>
And the code I will be adding to edit_profile.php (in the right spots):
Code:
<tr><td>Analytics Code: </td><td><input type="text" name="analytics" value="<?php echo $profile['analytics']; ?>"></td></tr>
$profile['analytics'] = $h->cage->post->('analytics');
I understand that this is not the most elegant method, but here is what all of this should achieve so far:
- If the author of the current page has entered their analytics ID in their profile, the Analytics tracker will be activated.
- If the author of the current page has NOT entered their analytics ID, nothing will happen
- The analytics ID will be displayed as UA-12345-1 (example), surrounded by single quotes only.
Now, before I figure out how to set up a test environment (i'm thinking of just copying everything over to a subfolder (i.e. "demo") and loading the site from there (i.e. site.com/demo).. is that how you set up test sites?), does all this look like it will, at least, logically work? I'm very cautious about simple syntax errors at this point because it probably won't be apparent to me if something is off or not. Thanks again for your help Nick (and anyone else who decides to comment
)
Also, now that I'm looking at it, should I place <?php before that entire block of code, since it ends with ?> ?
Bookmarks