UTF16 encoding of plugin string breaking google analytics?

I strongly suspect now that this:

Is actually a tutor-specific issue related to it seemingly doing UTF-16 encoding of the “-” character (from ASCII 0x2D to UTF-16 “\u002D”). You can see in the below hexdump that it definitely starts off as an ASCII 0x2D. But then as show in the above open edx forum posts, it ends up in javascript as \u002D, which causes google analytics to not work.)

Is there any way to alter this encoding behavior?


> hexdump -C $(tutor plugins printroot)/GoogleAnalytics.yml
> 00000000  6e 61 6d 65 3a 20 67 6f  6f 67 6c 65 61 6e 61 6c  |name: googleanal|
> 00000010  79 74 69 63 73 0a 76 65  72 73 69 6f 6e 3a 20 30  |ytics.version: 0|
> 00000020  2e 31 2e 30 0a 70 61 74  63 68 65 73 3a 0a 20 20  |.1.0.patches:.  |
> 00000030  6f 70 65 6e 65 64 78 2d  63 6f 6d 6d 6f 6e 2d 73  |openedx-common-s|
> 00000040  65 74 74 69 6e 67 73 3a  20 7c 0a 20 20 20 20 23  |ettings: |.    #|
> 00000050  20 67 6f 6f 67 6c 65 61  6e 61 6c 79 74 69 63 73  | googleanalytics|
> 00000060  20 73 70 65 63 69 61 6c  20 73 65 74 74 69 6e 67  | special setting|
> 00000070  73 0a 20 20 20 20 47 4f  4f 47 4c 45 5f 41 4e 41  |s.    GOOGLE_ANA|
> 00000080  4c 59 54 49 43 53 5f 41  43 43 4f 55 4e 54 20 3d  |LYTICS_ACCOUNT =|
> 00000090  20 22 55 41 2d 32 30 31  34 34 33 33 30 36 22 0a  | "UA-201443306".|
> 000000a0  20 20 20 20 47 4f 4f 47  4c 45 5f 41 4e 41 4c 59  |    GOOGLE_ANALY|
> 000000b0  54 49 43 53 5f 54 52 41  43 4b 49 4e 47 5f 49 44  |TICS_TRACKING_ID|
> 000000c0  20 3d 20 22 55 41 2d 32  30 31 34 34 33 33 30 36  | = "UA-201443306|
> 000000d0  2d 31 22 0a                                       |-1".|

@oedx

Which version are you using ?
I tested integrating Google analytics in Koa and it’s working fine.

I’m using Koa & Tutor 11.3.1

Hi @oedx
Can you verify the plugin content (specifically whether account and ID are enclosed in double quotes) ?

name: googleanalytics
version: 0.1.0
patches:
  openedx-common-settings: |
    # googleanalytics special settings
    GOOGLE_ANALYTICS_ACCOUNT = "UA-xxxxxxxxx-x"
    GOOGLE_ANALYTICS_TRACKING_ID = "UA-xxxxxxxxx-x"

Yes, you can see in the above hexdump that the double quotes are used, and correspond to hex 0x22 which is ASCII " (I was worried for a second when you said that, that maybe a unicode “curly quote” had been inserted, but it doesn’t look like it.)

Non-hexdump form is:

name: googleanalytics
version: 0.1.0
patches:
  openedx-common-settings: |
    # googleanalytics special settings
    GOOGLE_ANALYTICS_ACCOUNT = "UA-201443306"
    GOOGLE_ANALYTICS_TRACKING_ID = "UA-201443306-1"

(Also, can you look at the page source for your page, and let me know if you also see
_gaq.push(['_setAccount', 'UA\u002D201443306']);
i.e. with the encoded -, or if it just shows up as a -?)