Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyroCMS 2.2.5 Update for Google Analytics Dashboard #3503 #3544

Closed
ikoniqoz opened this issue Oct 6, 2015 · 38 comments
Closed

PyroCMS 2.2.5 Update for Google Analytics Dashboard #3503 #3544

ikoniqoz opened this issue Oct 6, 2015 · 38 comments

Comments

@ikoniqoz
Copy link

ikoniqoz commented Oct 6, 2015

Background:

  1. I have already upgraded a PyroCMS 2.1.5 site to the latest following last merge on 14-AUG to include resolution for Update for Google Analytics Dashboard #3503. In this case, the GA Update appears to have been fully implemented OK.
  2. I have now updated a client's PyroCMS 2.2.5 site which was from prior to the Update for Google Analytics Dashboard #3503 merge AND I installed a NEW site based on the latest updates for Update for Google Analytics Dashboard #3503. On both occasions the update was not fully implemented.

Observations:
All files for the updates were either updated or created. These included:

  • libraries/Analytics.php
  • libraries/Gapi.php
  • migrations/130_alter_ga_settings.php { NOTE the word "alter" first letter is not capitalised. }
  • plugins/integration.php

However the db fields were not updated according to the migrations file. Is that what is supposed to happen ?

I note that the Labels and Descriptions for the GA Email and GA Password fields in Dashboard -> Settings -> Integration are derived from the Settings Module's lang file (setting_lang.php) - not the settings db table which was not updated. So, to get the field Labels and Descriptions correct I had to manually edit the settings_lang.php file.

One other point is that I edited the ga_password field type in the settings db table by changing it from password type to text type and I could then enter the path to the ga-key.p12 file.

Right now, I do not know if these changes I have made to the client's site work as expected for the GA stuff as it has not yet been pushed thru to Production. Nevertheless, there is enough here to cause me some concern.

Bottom Line: Does anyone have PyroCMS 2.2.5 with the merge for #3503 from 14th Aug fully functional ?

Just in case this is relevant, my dev system is Win7 with PHP 5.3.5

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 6, 2015

Upgrade a 2.1.5 site to 2.2.5:

Firstly, the Password field was changed from a password type to a text type and the path to the ga-key.p12 file is in the field as the value for this field, but no default value is included.

Next, neither of the field Labels or Descriptions been updated on the GA Email or GA Password fields.

@marcogrueter
Copy link

What value do you have in the migrations table?
And yes, the labels and descriptions have not been updated yet.

And I'm not sure what you mean by "and the path to the ga-key.p12 file is in the field as the value for this field, but no default value is included" - the path is the default value.

But the non-capitalized name of the migration file is certainly a mistake.

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

I have 340 in the Migrations table.

The actual path to the ga-key.p12 is displayed in the Analytics Password field. That is: "system/cms/config/ga-key.p12"

Hope this helps...

@marcogrueter
Copy link

340? Are you sure?
The migration is numbered as 130 - so the number of the previous version should be 129, and as soon as you pulled in this commit and let the migrations run, it should be at 130.

Are you running your own migrations?

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

Oh - Sorry - Typo. It is 130 as it should be.

Dont know how to run my "own migrations". Just did standard upgrades on each site..

@marcogrueter
Copy link

Ok. Soooooooo... the migrations ran, the value in the Analytics Password field is there, the files were written. Do you see the GA dashboard in the backend?

I'll checkout out a fresh installation based on this commit and see what's going on.

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

Good question !! As yet, I have not published the client's site - that will be next week sometime. So the answer is no - sorry..

@marcogrueter
Copy link

But you have that installation somewhere, don't you? As long as you provide the .p12 file and set the service account e-mail in the ga_email field you should be able to see the graphs. Would be great if you could test this.

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

Hmm. I could try using a known GA account.. I will try and report back.

By the way, I have mentioned 2 different sets of results from 2 different upgrades.

@marcogrueter
Copy link

Wasn't the result in either case that the migrations didn't run?

Upgrade from 2.1.5 to commit -> worked
Upgrade from 2.2.5 to commit -> migration missing
New Site based on commit -> migration missing

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

Upgrade from 2.1.5 to commit did not change the form field's "value" or "default" attributes.

@marcogrueter
Copy link

Ok, so that means the migrations didn't run either in this case. Was this all tested on your local Windows dev machine? Usually Windows isn't too sensitive about the case ^^

Well, I'll look into it sometime during the weekend.

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

BTW: I have tried on two 2..1.5 -> 2.2.5 upgrades with your commit. One of these was my own site - however, there is another issue which resulted from the upgrade which impacts the Navigation module. Most probably due to another PR prior to yours.
So, I have entered the GA Email address and added the key file. What else needs to be done to get the graph to be displayed ?

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

Yes - all done on my Win 7 dev system. I did try changing the case of the migration filename from 130_alter_.... to 130_Alter... but that had no effect which did not surprise me. Sorry I dont have a linux install running...

@marcogrueter
Copy link

You'll also need to enter de profile ID in the respective field (which should already exist if you've upgraded from a version that had a working dashboard) - and that should be it.

GA E-Mail address has to be the address of the service account you created (usually a very long string, followed by @developer.gserviceaccount.com)

@marcogrueter
Copy link

try changing the value in the default_migrations table back to 129 (with the changed filename of the migration) and check if that does something. Make sure you change the value of the ga_password field to something else than system/cms/config/ga-key.p12 so that a change will be visible.

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

OK - I have to leave this now. Is there some way we can communicate apart from within this Issue ? How about Skype ? I will be back at my desk in about an hour.

@marcogrueter
Copy link

Uh sorry, I don't really have time to do a skype session and whatnot - I'm still at work and will be for another 8-9 hours. I'll check the issue out during the weekend and report back.

@ikoniqoz
Copy link
Author

ikoniqoz commented Oct 7, 2015

OK - Thanks. Cheers for now.

@ikoniqoz
Copy link
Author

@marcogrueter Any progress on this ?

@bloveless
Copy link
Member

@ikoniqoz I was able to get Google Analytics working without changing anything. Is there still something that you are having an issue with? I did update the notice at the top of the page so it will help the user figure out why it is not displaying correctly.

@ikoniqoz
Copy link
Author

@bloveless - Thanks for the followup. I have a new client site with all the new GA changes - uploaded Friday pm. I see the warning message now. Thanks. However, that also means that I am not able to see the Analytics graph. SO, still something Not Quite Right here.

Also, I see that the 130_ migration file name still needs an Uppercase first character. I am assuming that this is not contributing to my problem since the updates were manually carried out on my dev copy of this site prior to upload..

@bloveless
Copy link
Member

The migration is named correctly, but git doesn't track case changes by default. https://github.com/pyrocms/pyrocms/tree/2.2/develop/system/cms/migrations Look there. You'll see it has changed.

Also what error message are you getting. It took me about an hour of messing around in the google API dashboard and google analytics to get the analytics to show up correctly. I promise it does work if you set up Google correctly and put your key in the path listed in the Google password area of the settings.

@ikoniqoz
Copy link
Author

@bloveless Thanks for the feedback and the filename details. The error I am getting is: "Could not connect to Google Analytics. Check in Settings." - Like you I have spent quite some time in Google API land etc.. The key file is located in system/cms/config and is named ga-key.p12. I also have this path entered into the API Key Path field of the Settings form and have the Service Account email address in the Google Service Account Email field.

@bloveless
Copy link
Member

If you pull the latest from 2.2/develop you should get another commit of mine that will expand on that error message. It should be saying GAPI: on the line below Check in Settings.

@bloveless
Copy link
Member

You also need to give access to that email address to your google analytics and add google analytics as a service in your google dashboard. https://github.com/erebusnz/gapi-google-analytics-php-interface follow the instructions at the bottom of that repo. I was missing step 3 and 4 when I did it.

@bloveless
Copy link
Member

This is the commit that i'm referring to. You should have it if you pull the latest from 2.2/develop

c7e148f

@ikoniqoz
Copy link
Author

OK - Thanks. I missed editing that line.

I see that the Instructions you mentioned on github/erebusnz mention: "Download the .p12 file for this service account, upload to the same folder as gapi.class.php". Thats a new one for me. Is this already covered by Marco's work ?

@ikoniqoz
Copy link
Author

@bloveless I have done a fresh install from todays latest and note that in Setttings->Integration the Service Account email field has not been changed from the old Google Analytics email field and the GA-Key field has not been changed from the old Google Analytics Password field. So, the points I made at the top of this issue still prevail. I am on Win7 with PHP 5.3.5..

@RyanThompson
Copy link
Member

@bloveless what's scoop here? Working solution / needs migration fix?

@bloveless
Copy link
Member

@RyanThompson I've been able to get this working with no code changes. It is a pain in the ass to get google analytics working correctly, but I've been able to get analytics to show up in a new 2.2/develop project. I added better error handling, but really no significant code changes.

@ikoniqoz If the password field is not showing the key then make sure you are checking out 2.2/develop and not 2.2/master. These changes are not part of 2.2/master. Also when you upgrade the defaults will not be applied. If you had an old google analytics email address and password in there then you will need to manually put in the new service account email and the key path. The upgrade will not do that for you.

@RyanThompson
Copy link
Member

@bloveless ready for a merge? Ima lean on you for this one if that's ok.

@ikoniqoz
Copy link
Author

ikoniqoz commented Nov 3, 2015

@bloveless In the fresh install I mentioned (7 days ago above and downloaded on 27-OCT-2015 ) I indeed had Migrations files 130 and your 131. I also had in system/cms/libraries both of Marco's Analytics.php file and the Gapi.php file. Plus, I have your recent edit to the pyrocms theme's theme.php file. All confirmed.

So, to satisfy curiosity, I downloaded another copy of the dev branch this morning and did another fresh install. After the install, I note that "the points I made at the top of this issue still prevail."

So, just to re-iterate, in Settings -> Integration the Google Analytic E-mail field and the Google Analytic Password field still remain - they have not been changed (by migration 130 ?). These fields are getting the Label title and accompanying description from the Settings Module's settings_lang.php file and the password field is still set as a password input field displaying a bunch of asterisks. Thus, the default_settings database table has not changed - which was interpreted by Marco to indicate that the Migration 130 did not run.

As mentioned in a previous post above, I have a new client's site in production where the Analytics graph does not appear - in its place I get the amended message which includes: GAPI: Failed to request report data. Error: "User does not have any Google Analytics account." My dev system is Win7 with PHP 5.3.5, and Production server is PHP 5.3.9

@bloveless
Copy link
Member

After a fresh install, and my google configurations my settings look like this. The value I've got for Google Analytics Password is the default one that came when I installed. I didn't update that at all, but just put the key in the location specified in that input field.

screen shot 2015-11-02 at 5 28 32 pm

I can see in my database that every migration has run.

screen shot 2015-11-02 at 5 29 56 pm

And my dashboard looks like this.

screen shot 2015-11-02 at 5 28 19 pm

Where does your differ? Send some photos!

@ikoniqoz
Copy link
Author

ikoniqoz commented Nov 3, 2015

@bloveless Thanks for the quick response.
I will start with the client's site I mentioned above. I checked the migrations db table and it is at 130. I manually edited the theme.php file.
The first image below is from that site. I dont include the graph since it is not displayed - instead, I get the error message.
The second image below is from the new install mentioned above. Note the asterisks.
screenshot-1

NEW INSTALL THIS MORNING. Migrations is at 131.

screenshot-2

@huglester
Copy link
Contributor

Hello,

I somehow can't manage it to work.
I see old settings after updating to newer version.

I don't see those 'key paths', etc, like shown here:
https://cloud.githubusercontent.com/assets/3609155/10898666/fe13a442-8220-11e5-8480-2a09a7f5fd16.png

Any idea what I could have done wrong?

@huglester
Copy link
Contributor

I found an issue. Migrations did run.
But inside the migrations I don't see any mentions of 'Google Viewer Id'

Connecting the "p12" key gives an error:

GAPI: Failed to authenticate user. Error: "{ "error": "invalid_grant", "error_description": "Bad Request" } "

Probably this key is badly generated? Also whilegenerating a key, it sais it's password is notasecret, should this password be set somewhere?

@ikoniqoz
Copy link
Author

ikoniqoz commented Nov 9, 2015

@huglester I believe that the notasecret password has been included in the gapi.php library file.

Also, the Settings -> Integration Google Analytics Email address field and the Google Analytics Password field label and description are derived from the settings module's language file so they dont actually get changed. Also, the password field is set to be a password type in the settings db table and needs to be changed from a password to a text field. So there are a number of things here that are not quite right for me, even tho @bloveless has had more success than you and I. In a post above this @bloveless refers to Step 3 and 4 of the Instructions for setting up a Google Service account here: https://github.com/erebusnz/gapi-google-analytics-php-interface - Did you do step 4 ?

Good luck, and I hope that you can get this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants