PHP Snippet before & after
| Project: | Google Analytics |
| Version: | 6.x-2.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I think it would be great to add two PHP code snippet blocks in the advanced section to dynamically control the javascript that is rendered. This feature would give me the ability to set some javascript variables using the Drupal variables in PHP. For example...
1. There are situations where I might want a taxonomy term or other Drupal Variable to be recorded in my Google Analytics report. It would be great if I could write some PHP to control GA's User Defined Variable with this javascript function:
print "pageTracker._setVar('DRUPAL_TAXONOMY_TERM');"
2. There are situations were I might have multiple customers who want to track their google analytics in a separate GA account. I would want to make use of a PHP Snippet After block to output javascript using a CCK field...
print "var otherTracker = _gat._getTracker('CCK_FIELD_CUSTOMER_GA_ID');"
print "otherTracker._trackPageview();"
As you can see, it would be awesome to blend the power of PHP variables with GA's javascript.
Peace,
Brian

#1
There is no way to re-use setVar if you already use Segmentation. Implementing this would cause other issues, but please provide a patch.
The CCK stuff is a duplicate of #324764: support for multiple analytics keys.