I'm trying to set the User-ID for Google's new Universal Analytics, but it keeps erring saying " SyntaxError: Unexpected token '{' ".

Here is my code;

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', 'UA-XXXXXXXX-X', 'auto');
{if logged_in}
ga('set', '&uid', {{{member_id}}});
ga('send', 'pageview');

I have tried this with $env_config['protect_javascript'] = 'y' and $env_config['protect_javascript'] = 'n';.

1 Answer 1


Why do you have 3 sets of parenthesis around the member_id tag?

Does it work if you simply use {member_id}?

EDIT (after comments) I'm not completely sure how this should be set up as I've never used this (will need to get up to speed on it though) but based on what I see in the docs does this work;

{if logged_in}
    ga('create', 'UA-XXXX-Y', { 'userId': '{member_id}' })
    ga('create', 'UA-XXXXXXXX-X', 'auto');

I'm not sure why the docs show UA-XXXX-Y for the user ID section.

  • 2 of the parenthesis are required for Universal Analytics to track a user ID as {{USER_ID}}); Commented May 14, 2014 at 11:21
  • Looking at the docs here developers.google.com/analytics/devguides/collection/… it looks slightly different to how you're doing it.
    – foamcow
    Commented May 14, 2014 at 11:42
  • Indeed, it's a bit confusing because the developer docs show the way above. But when you create a new Universal property with User ID, it shows the markup i have above. Commented May 14, 2014 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.