we would like to track our anonymous visitor IP addresses in order to differentiate internal vs external traffic, but we are having a problem because cached boost .html pages can't really get the IP address to pass into the google analytics for us to use.

has anyone ever figured out how to track user IP's with boost installed?

CommentFileSizeAuthor
#2 boost-622398.patch4.98 KBmikeytown2

Comments

mikeytown2’s picture

Use the Boost ajax stats block and Enable access log under admin/reports/settings.
Report is located at admin/reports/hits inside each report is the IP. I'm sure theres a module out there so you can follow the user by IP
http://drupal.org/project/modules?filters=drupal_core%3A87%20tid%3A119&s...
Report back here any findings so others looking can find this info in one place.

Google analytics runs client side (javascript) not server side (php) so page caching should have nothing to do with it not working. There could be a slight chance it won't work if the cached page is fairly old & on admin/settings/googleanalytics -> Advanced settings -> "Cache tracking code file locally" is checked along with "Optimize JavaScript files" being enabled and if Boost is caching javascript. No way around this, I might want to create a warning on the status page if this is set and the html expiration time is longer then 24 hours. If this is the case, disable "Cache tracking code file locally" in the googleanalytics module. No way around this, if this is what's causing the issue.

mikeytown2’s picture

Version: 6.x-1.13 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new4.98 KB

Check for the googleanalytics module on the status page

mikeytown2’s picture

Title: track user IP » Warn if googleanalytics & boost might have a configuration setting that is not optimal.
Category: support » task
chadd’s picture

i don't think that's why it isn't working. generating the user's IP is easy, we have added a line of php to the template.php file that gets the users IP address, save that to a javascript var when the page loads, then we add that var to the custom javascript in the google analytics module so it saves that var (the user's IP) as one of our custom variables in our google analytics account.

the problem comes when the cached html page is created, it is created with the IP of the user that creates the html page, so then from then on, every user, no matter what IP, that is served that html page, gets logged into analytics with the initial user's IP, since his IP is the one the template.php file generated and subsequently boost hardcoded that IP into the cached html file.

mikeytown2’s picture

Status: Needs review » Closed (fixed)

we have added a line of php to the template.php file that gets the users IP address

Next time can you give more details, like the fact that you have a special template.php file? That php file will not run if your page is cached, even with the core cache. With your current setup this is not a problem specific to boost.

You will need to do an ajax callback to set that variable.
http://groups.drupal.org/node/24825
So instead of writing to the DOM you save it to a javascript variable. Once that variable has been set, trigger the google analytics code to run.

chadd’s picture

sorry, i thought the template.php file was standard to most every drupal theme, not something special we had. didn't even think to mention that.

and i understand that the template.php file will not be called if the page is cached, as i understand it, that's the whole point of boost, that it returns the html file instead of the php to make things faster.

so that was my question, how do you get the php IP address variable if the page is cached. i'll have to try it with the ajax callback. i think i know exactly how i'm going to do it now. thanks for the tip.