This object is in archive! 
Google Analytics & USER_ID
Google has a User-ID feature that allows you to add the following to the GA code:
- ga(‘set’, ‘&uid’, {{USER_ID}}); // Set the user ID using signed-in user_id.
What I am looking for is how to render the User ID inside of UseResponse. I am assuming it has to be something similar to how the site_title is rendered.
- <?php echo Singular_Core::_('Settings')->getSetting('site_title')?>
How do I render out the User ID? I am adding this to head.phtml, BTW.
Could you please clarify the purposes of rendering user id in head.phtml?
If it's for Google Analytics then you can place any tracking code in Administration-Analytics-External Scripts section in head, so you don't need to change anything inside scripts
Could you please clarify the purposes of rendering user id in head.phtml?
If it's for Google Analytics then you can place any tracking code in Administration-Analytics-External Scripts section in head, so you don't need to change anything inside scripts
I know we have been over this one before. I have never, in fact, been able to see what wonderful settings you actually have in the Analytics section of the Admin because this:
IIRC it is because we are running PHP 5.5, more specifically 5.5.17, and this is a feature that you have already stated that will be "fixed" by the 3.x release.
But regardless of this fact, I need to add a customization to the GA code block, to support the User ID. And yes, I am choosing to put my GA code in the head of the document, not the footer. My GA block of code will look like this, when it works properly:
So, I need to know how to write the variable for the User ID into the template for this reason.
I know we have been over this one before. I have never, in fact, been able to see what wonderful settings you actually have in the Analytics section of the Admin because this:
IIRC it is because we are running PHP 5.5, more specifically 5.5.17, and this is a feature that you have already stated that will be "fixed" by the 3.x release.
But regardless of this fact, I need to add a customization to the GA code block, to support the User ID. And yes, I am choosing to put my GA code in the head of the document, not the footer. My GA block of code will look like this, when it works properly:
So, I need to know how to write the variable for the User ID into the template for this reason.
Hello,
The most easier way to retrieve user id in any place of code is:
So, you can insert GA code inside your layout and inject user id as I wrote above.
Unfortunately Analytics section is not supported by PHP 5.5 and upper, but we have added PHP 5.5.* full compatibility in UseResponse 3.*.
Hello,
The most easier way to retrieve user id in any place of code is:
So, you can insert GA code inside your layout and inject user id as I wrote above.
Unfortunately Analytics section is not supported by PHP 5.5 and upper, but we have added PHP 5.5.* full compatibility in UseResponse 3.*.
Thank you Paul!!
Thank you Paul!!
This seems to be the correct way to handle this, for reference if anyone else wants to do the same thing:
This seems to be the correct way to handle this, for reference if anyone else wants to do the same thing:
It looks like I cannot edit my comment, and it also looks like there is some confusion because of the Google documentation on this, below is the correct code.
It looks like I cannot edit my comment, and it also looks like there is some confusion because of the Google documentation on this, below is the correct code.
Hello,
You can edit your comment within 30 minutes after adding (if you are not Agent or Admin).
I have another solution for your case how to get user id by using Javascript only:
Note: you need to apply this implementation when application.js is loaded or after all minified javascripts are loaded if you are using assets compression feature. For example, you can simply apply this code inside templates/layout/header.phtml
Hello,
You can edit your comment within 30 minutes after adding (if you are not Agent or Admin).
I have another solution for your case how to get user id by using Javascript only:
Note: you need to apply this implementation when application.js is loaded or after all minified javascripts are loaded if you are using assets compression feature. For example, you can simply apply this code inside templates/layout/header.phtml
I was way outside the 30 minute limit ;)
That is a good solution for JS, I agree, but since the GA code is in JS, I think the PHP solution is what is needed here.
I was way outside the 30 minute limit ;)
That is a good solution for JS, I agree, but since the GA code is in JS, I think the PHP solution is what is needed here.
As you wish :-)
Have a nice day!
As you wish :-)
Have a nice day!
Replies have been locked on this page!