admin管理员组

文章数量:1406937

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 / but what is the problem?

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./blog/google-tag-manager-custom-javascript-variable-examples/ but what is the problem?

Share edited Jan 17, 2017 at 11:22 user1271930 asked Jan 17, 2017 at 11:17 user1271930user1271930 3411 gold badge8 silver badges22 bronze badges 2
  • can I just ask why there are no braces around your if statement? – Ben Davison 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, :) – nyuen Commented Jan 17, 2017 at 14:47
Add a ment  | 

1 Answer 1

Reset to default 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.

本文标签: Google Tag Manager custom Javascript quotUnknown variable Click IdquotStack Overflow