Updated: Comment #13

Problem/Motivation

The widget js would be loaded but now analytics would come through to addthis.com.

The problem is a invalide url to the widget.js. It was ending with addthis_widget.js#pubid=012345?async=1 while it should be addthis_widget.js#pubid=012345&async=1. Besides that it is including the widget.js after the DOM is ready.

Proposed resolution

Fixing the url structure and adding the domready type of loading and simple include through the UI.

Remaining tasks

Nothing.

User interface changes

Adds a new configuration option to the Advanced Settings tab for AddThis.

API changes

No API changes.

Original report by walangitan

I'm having trouble getting analytics to register on addthis.com

Checking the script like they suggest by typing addthis_config.pubid to see if it matches to the profile ID for the site results in an "undefined" for me and I can't figure out how to fix this.

Comments

leon kessler’s picture

I've got the same problem, think maybe the addthis API has changed.

I got it to work by going to admin/config/user-interface/addthis/advanced and enabling advanced configuration.
I copied everything currently from my addthis_config and added pubid
(Can't confirm it's 100% working yet as no reports have come through, but my email template is which means it's picking up the account at least).

Looking into the module, think the problem might be within addConfigurationOptionsJs() in classes/AddThis.php, the configuration array in this file doesn't include the profile.

khalib’s picture

What's breaking the analytics is that the JS that the module is outputting appends a query param. Since the AddThis JS path has the account ID after a hashtag, the string being appended causes the AddThis account ID to be invalid:

"addthis":{"widget_url":"http:\/\/s7.addthis.com\/js\/300\/addthis_widget.js#pubid=ra-51c1ed312e03e156?async=1"}

AddThis is reading the JS call with the ID of: pubid=ra-51c1ed312e03e156?async=1

as suppose to: pubid=ra-51c1ed312e03e156

icdq’s picture

same problem for me, any possibility to fix?

kyawzayl’s picture

Same here as well. Analytics data are not showing in addthis account. Any fixes?? Thanks.

jtherkel’s picture

Is this as simple as commenting out line 196 of addthis/classes/AddThis.php? (I'm just guessing.) I just tried this on my Dev site, and I'll report back if it works.

  public function addWidgetJs() {
    //$async_parameter = self::isWidgetJsAsync() ? '?async=1' : '';

Unfortunately, it will take around 24 hours because my Dev site is on a different domain from Production. AddThis takes a little while to recognize a new subdomain (more below).

If you're brave enough to try this on your Prod site, log into AddThis and view data for the 24 hour period. Here are some relevant links and quotes from the AddThis support site.

Data Freshness
"Reports that use the 24-hour view will update every 5 minutes and will contain data as recent as 10-20 minutes ago. Reports for daily periods like 'last week' will update nightly, at approximately midnight eastern time, and may take up to 24 hours to appear."
http://support.addthis.com/customer/portal/articles/381258-data-freshnes...

AddThis Account for multiple websites
"New domains can take about 24 hours to show up from the first time they're shared."
http://support.addthis.com/customer/portal/questions/262636-add-this-acc...

Here's the command I used to search my source code for the relevant file.

grep -i -r "async" sites/all/modules/contrib/addthis/

dijup tuladhar’s picture

Hi JT,

Did it worked for you?
I am having same problem with the module there is nothing my analytic page. Is there any way to check the debug the setting?

Please let me know if it works for you.

Thank you,
Dijup

jtherkel’s picture

Sorry Dijup, it did not work for me. I would have posted here sooner if I had achieved success. :) It's a little tricky to change some code and wait 24 hours to see if it worked.

hawkeye.twolf’s picture

StatusFileSize
new604 bytes

Hi, John.

You were on the right track. I don't know what the "is widget js async" variable does, but it doesn't actually get set anywhere in the AddThis module code, so it always uses the default value (TRUE). Changing it to FALSE causes that function to load the JS file directly from AddThis.com, which correctly loads the dependent JS files as well. I'm guessing that variable is a legacy of older AddThis API integration and perhaps we no longer need it.

A patch is attached, and it works for me. Also note that the AddThis analytics picked up my new domain almost instantly; it didn't take the full 24 hours.

Cheers,
Derek

nico.knaepen’s picture

Hi Derek,

There's no need to write in the AddThis.php class because this can be easily fixed by setting a variable
variable_set('addthis_widget_async',FALSE);
The variable_set can be done in a custom module update hook.

Regards,

Nico

matglas86’s picture

Assigned: Unassigned » matglas86
Issue summary: View changes
Priority: Normal » Major
matglas86’s picture

matglas86’s picture

Status: Active » Needs review
StatusFileSize
new6.15 KB

It came down to two problems. One the url for the widget was incorrect. It contained a ? instead of a & sign. And the async method requires that the addthis is loaded at rendering and triggers a init() after everything is loaded.

Now I fixed several things.

  1. I fixed it the url issue.
  2. I implemented the domready type of loading. This says: load the whole script when everything is loaded already.
  3. I made the domready the default implementation.
  4. Everything has been tested for tracking.

What is still left to do.

  • Test it in your setup.
  • Adjust testing code to work with the new configuration screen and class.

You can download this version of the module here.
https://github.com/matglas/addthis/archive/issues/1919156-no-tracking.zip

This is the patch seen on github.
https://github.com/matglas/addthis/compare/7.x-4.x...issues%2F1919156-no...

matglas86’s picture

Version: 7.x-4.0-alpha2 » 7.x-4.x-dev
Issue summary: View changes
StatusFileSize
new1.83 KB
new6.5 KB

In my last patch I made 'domread' the default but for consistency reasons with past versions I thought it woulde be good to make async the default.

Besides that I moved the loading of the widget script to the footer. This is only applicable to 'async' and 'include' type loading.

There are now three types of widget js loading.

  • async (default): Asynchronous. This load the scripts but initializes all the resources when addthis.init() is called.
  • domready: The DOMReady style is adding the widget js after everything is loaded.
  • inlclude: Is the behaviour where it is just include as js.
matglas86’s picture

StatusFileSize
new6.5 KB

Re-roll against head of 7.x-4.x

matglas86’s picture

If I don't receive feedback in the coming week I'm going to apply the patch and close the issue. I want to make some progress on the issues.

matglas86’s picture

Status: Needs review » Fixed

Fixed this issue. If any problems arise please reopen a new issue with a reference to this one.

Commit: 68aa4

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.