The tracking solution I use requires that I enter a little snippet of php code at the top of each node.

Is there a module or work-around that someone can recommend which I can set up to insert this bit of PHP "automagically" into the top of the body of each node I create?

Thanks,

Ron Jones

Comments

gforce301’s picture

You can just put the php code you need in your page.tpl.php and it will execute on every page on your site.

Ron Jones’s picture

I've tried it that way, but it didn't work. I guess it needs to be within the <?php print $content; ?> operation.

So, I tried downloading contemplate thinking that it would do the job. And it might...but It seemed like overkill for what I wanted.

All I want is for the following code to be placed automatically at the head of the body of any content type node I create:
<?php error_reporting(0); $cookiename = 'xconversions'; if (isset($_COOKIE[$cookiename])) $var = $_COOKIE[$cookiename]; ?>

Thanks,
Ron

gforce301’s picture

I guess it needs to be within the print $content; operation.

Sorry but this does not make sense to me. Can you post the code you need to use?

Ron Jones’s picture

Yes, I need to insert the following:

<?php error_reporting(0); $cookiename = 'xconversions'; if (isset($_COOKIE[$cookiename])) $var = $_COOKIE[$cookiename]; ?>

in the body box of every node that I create. Of course, I can do it by hand. However, I just wanted to plug the snippet into something simple and have it appear automatically before I pasted in my content.

gforce301’s picture

Did you try putting it in the node.tpl.php template instead? Or are you actually trying to have it pasted into the "body" textarea on the node form?

Ron Jones’s picture

The first thing I did was try putting it in node.tpl.php: <div class="content"><?php error_reporting(0); $cookiename = 'xconversions'; if (isset($_COOKIE[$cookiename])) $var = $_COOKIE[$cookiename]; ?><?php print $content; ?></div>

I also tried: <div class="content"><?php error_reporting(0); $cookiename = 'xconversions'; if (isset($_COOKIE[$cookiename])) $var = $_COOKIE[$cookiename]; print $content; ?></div>

And: <div class="content"><?php print $content; error_reporting(0); $cookiename = 'xconversions'; if (isset($_COOKIE[$cookiename])) $var = $_COOKIE[$cookiename]; ?></div>

While my site worked just fine, I still had no tracking; So...

Next, I did some researching on the vendor's forum and discovered that it has to go into the "body" text area on the node form.

This is not a "written in stone" thing, but it's the best answer I could get. Most of the users trying to integrate it into a CMS are wordpress users; and in that environment, it has to go into the "body" text area.

I made a test post with each different solution I tried, and it would appear that the operational environment bears this out (I posted the snippet by hand (into the "body" text area) and it functioned as designed).

dnewkerk’s picture

It is not recommended that you use a PHP enabled input format for your general content. Whatever you do, do not in any case use PHP input format with any user besides yourself, or your site will be easily compromised.

I cannot imagine why PHP like this would need to go "in" the $content area or Body field of the node. What software/module are you using that is asking you to do this?

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

scoutbaker’s picture

It appears to be tracking code for extreme conversions which, from a 10-second glance at the page, is supposed to help target your Google adwords campaigns. Of course, not being a paying customer, I have no clue about what/why the OP is being told what they are.

---
"Nice to meet you Rose...run for your life." - The Doctor
My first public Drupal site - EyeOnThe503

Ron Jones’s picture

Yes, that is correct.

Why does it needs to go "in" the $content area or Body field of the node? because it will not work when merely pasted into the template.

As another poster correctly surmised, the software is called Xtreme Conversions. Designed to help track conversions at the keyword level for both PPC and organic traffic.