WordPress.org

Ready to get started?Download WordPress

Forums

Google Analytics for WordPress
cross domain tracking (19 posts)

  1. vzaguski
    Member
    Posted 2 years ago #

    Couldn't enable cross domain tracking - "_link" event is not set for specified domains and they just tracked as outbound articles.

    After looking through code I've found the line that could couse problem.

    Here's the code snippet:
    -----

    } else if ( $target["domain"] != $origin["domain"] ){
    					$crossdomains = explode(',',str_replace(' ','',$options['othercrossdomains']));
    					if ( $options['trackcrossdomain'] && in_array($target["host"],$crossdomains) ) {
    						$trackBit = '_gaq.push([\'_link\', \'' . $matches[2] . '//' . $matches[3] . '\']); return false;"';
    					} else if ( $options['trackoutbound'] && in_array($options['domainorurl'], array('domain','url')) ) {
    						$url = $options['domainorurl'] == 'domain' ? $target["host"] : $matches[3];
    						$trackBit = GA_Filter::ga_get_tracking_link($category, $url,'');
    					}
    					$trackBit = GA_Filter::ga_get_tracking_link($category, $url,'');
    				}

    ------
    [Code moderated: please ensure that your code is enclosed in backticks (`) or use the code button.]

    Actually, the last line in the code is the problem. If I delete it, it seems to work as expected.

    http://wordpress.org/extend/plugins/google-analytics-for-wordpress/

  2. pblickiss
    Member
    Posted 2 years ago #

    I'm having the same issue, even when disabling outgoing link tracking and commenting out the offending line of code from above. Does anyone have a fix for this in version 4.2.4? All links appear as outgoing whether they are listed in the specified domain list or not. Thanks!

  3. pblickiss
    Member
    Posted 2 years ago #

    Has anyone figured this out? Yoast doesn't appear to frequent this board often. Thanks!

  4. SocialBizzle
    Member
    Posted 1 year ago #

    We have a similar issue. Basically our conversion paths are not being tracked correctly between our site - socialbizzle.com and our payment processor - Fastspring.

    All conversions appear as a 'direct source' even though they are occurring through adwords and other marketing channels.

    I thought the problem would be solved now I have removed the 'track clicks and downloads option'.

    Are you saying that you have done that and it still doesn't work correctly?

  5. ThE_ED
    Member
    Posted 1 year ago #

    Had the exact same thing, as a quick fix, commenting out the line worked for me in the latest version (comment out the right line, there are multiple lines having the same code), but I'll try to find out as to why this behaviour occurs.

  6. wpaholic
    Member
    Posted 1 year ago #

    +1

  7. Paul G.
    Member
    Posted 1 year ago #

    +1
    This is a real problem... thanks for finding the quick fix.

    If you're out there Yoast, can ya take a look at this little bug - it's quite important for all cross-domain tracking.

    Thanks! :)

  8. worldwisewebs
    Member
    Posted 1 year ago #

    Seems to be working fine for me. I thought it was broken but realized I was logged in as admin. Doublecheck that's not the case for you!

  9. worldwisewebs
    Member
    Posted 1 year ago #

    erm actually I've got that wrong. What I am seeing is this:

    <a target="_blank" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','']);" href="http://my-out-bound-domain.org/">Outbound link</a>

    I tried checking and unchecking the option "Track outbound clicks & downloads:" and the onclick event stays either way. Strange?

  10. worldwisewebs
    Member
    Posted 1 year ago #

    It looks like the checkbox for "Enable Cross Domain Tracking:" is actually adding the _trackEvent instead of _link as expected. Checking this box also generates a notice:

    Notice: Undefined variable: url in {MY PATH}/httpdocs/wp-content/plugins/google-analytics-for-wordpress/googleanalytics.php on line 1161

    This notice appears whether or not the field "Cross-Domain Tracking, Other Domains:" is filled in.

    After a bit of playing around I did find that the original poster's fix does indeed work. The line at 1161 $trackBit = GA_Filter::ga_get_tracking_link($category, $url,''); overwrites the $trackBit variable that was set in the blocks just above it, so commenting out this line seems to resolve the issue for me.

  11. worldwisewebs
    Member
    Posted 1 year ago #

    Found another bug .. on line 1156, there is an extra double quote ta the end of this line, after the semi colon, before the closing single quote. $trackBit = '_gaq.push([\'_link\', \'' . $matches[2] . '//' . $matches[3] . '\']); return false;"';

    The double quote is closed again below when the $trackBit variable gets added into the $matches array, so this creates an extra quote that makes the link code a little screwy.

  12. magnusrf
    Member
    Posted 1 year ago #

    Man, I've been looking for a plug-in that could handle cross domain tracking for my websites for a LONG TIME. This plug-in is awesome.

    But just like vzaguski and worldwisewebs have indicated, line 1161 needs to be commented out and line 1156 needs to be updated to remove that last double quote.

    Works like a charm now!

  13. dDon
    Member
    Posted 1 year ago #

    I have been looking for a way to solve this as well, but I gave up after a few hours. I really hope this does the trick, I'll give it try tomorrow. Fingers crossed.

    Hope this gets solved in future updates though. Good work vzaguski and wisewebs.

  14. dDon
    Member
    Posted 1 year ago #

    It still doesn't seem to work.

    Even removing the last line vzaguski mentioned, it is still inserting '_trackEvent' instead of '_link'?

    Anyone got a fix for this?

  15. worldwisewebs
    Member
    Posted 1 year ago #

    Looks like these bugs made it to 3.4.5 - now it's line 1218 that needs to be commented out and the extra quote is on line 1213

  16. m.r.green
    Member
    Posted 1 year ago #

    Hi worldwisewebs,

    Yoast has now upgraded to version 4.2.7 but still has this issue. Would greatly appreciate if you could highlight the code again?

    Thanks,
    Mart

  17. Anointed
    Member
    Posted 1 year ago #

    Upgraded to 4.2.8, is problem still there? This thread says to edit lines, but does not say what file.

  18. jalancast
    Member
    Posted 1 year ago #

    I'm running 4.2.8 and the problem still exists.

    I've found and deleted the extraneous double quote (line 1218) as well as commented out the line that apparently ignores the previously set $trackBit variable (line 1223) and these fixes seem to work.

    Hopefully the developers will address these small issues in their next update.

  19. jalancast
    Member
    Posted 1 year ago #

    @Anointed - It's the main file - the first one you see in the plugin editor.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic