1.8K members online now
1.8K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
Guide Me

Outbound link event tracking gives "Command ignored. Unknown target: undefined"

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭


I implemented GA:

<script async src="{MY-ID}"></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{MY ID}');

I know it works as I can see it in my live report in GA, and my google chrome GA debugger happily sends the beacon for a pageview.

Following, I add the function for tracking an outbound link:

function handleOutboundLinkClicks(url) {
ga('send', 'event', {
eventCategory: 'Outbound Link',
eventAction: 'click',
eventLabel: url,
transport: 'beacon'

All of this is thrown in my head in my index.html.


Now my button looks like the following:


<button class="btn btn-block btn-lg btn-primary btn-masthead" onclick="window.location.href='{THE OUTBOUND LINK}'; handleOutboundLinkClicks('{THE OUTBOUND LINK}')"> >> Donate €10 <<</button>

When setting my GA Debugger config so that it doesn't delete the log after loading another page, I get the following message:


Executing Google Analytics commands.
VM1070 analytics_debug.js:10 Running command: ga("send", "event", {eventCategory: "Outbound Link", eventAction: "click", eventLabel: "{OUTBOUND LINK}", transport: "beacon"})
VM1070 analytics_debug.js:10

Command ignored. Unknown target: undefined
Navigated to {OUTBOUND LINK}

I'm hoping to be able to track these links to understand how people respond to my (external) CTAs, and to improve asap.

Thanks in advance.


1 Expert replyverified_user
Marked as Best Answer.
Accepted by topic author Yoni S

Outbound link event tracking gives &quot;Command ignored. Unknown target: undefined&quot;

Top Contributor
# 2
Top Contributor

Hi @Yoni S :-)

Your site is using gtag.js global site tag tracking code snippet.

The syntax for outbound link tracking differs a little to universal analytics.

Please find the correct code for the version of tracking code you are using, on the linked page


If you have further questions, please post back




Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Outbound link event tracking gives &quot;Command ignored. Unknown target: undefined&quot;

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Bronwyn,

That worked! Thanks kindly.

It's shown successfully in the GA debugger, and I see the event in my real-time dashboard. (Not yet in my reports, but I believe this can take ~24h, correct?)