4

I'm trying to access Click event related variables in custom javascript. Click event variables should be so called built-in variables but still it states unknown.

I'm using following syntax which is supposed to get ID of clicked link and return social media action per ID:

function() {
    var some = {{Click ID}};

    if (some == "tw")
        return 'tweet';
    else
        return 'share';
}

EDIT: For me it looks like I'm using variables just like on this page http://www.apasters.com/blog/google-tag-manager-custom-javascript-variable-examples/ but what is the problem?

2
  • can I just ask why there are no braces around your if statement? Commented Jan 17, 2017 at 11:43
  • There's no need for curly braces for single-line if statements, but I normally use them anyway for aesthetics, :) Commented Jan 17, 2017 at 14:47

1 Answer 1

7

You need to make sure that you have enabled/activated the built-in variables before you use them, otherwise you get that error message.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply! Now I realized that not all of them are "automagically" enabled and one must enabled them by checkboxes. Sadly, even the Google docs don't show this as a how to image or step by step list.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.