Problem/Motivation
Many sites use a form of hash-based navigation, to the point where it is often desirable to treat hash variants as unique pages for GA purposes. The URL submitted with a standard GA pageview does not include the URL fragment by default.
Proposed resolution
Allow GA module administrators to choose to include URL fragments in pageview logic. Provide a simple checkbox on the admin form. Reference this setting:
- Prior to writing the ga("send", "pageview") portion of the inline javascript generated in googleanalytics.module, and set the page value accordingly
- On any hashchange event captured in googleanalytics.js, and submit a pageview accordingly
Remaining tasks
- Review and test patch
User interface changes
Added checkbox to "Advanced Settings" section of admin form so that GA admins can choose to treat hash changes as pageviews and to include fragments in the page/path value submitted with each pageview.
API changes
None.
Related Issues
None known.
Comment | File | Size | Author |
---|---|---|---|
#9 | Issue-2092173-Optionally-Consider-URL-Fragments-Hash.patch | 5.19 KB | hass |
Comments
Comment #1
ndewhurstPatch attached. I've tested this code locally (with admin option enabled/disabled) and am seeing the expected behavior in GA real-time content reports.
Comment #2
ndewhurstUpdating patch to remove unnecessary line.
Comment #3
hass CreditAttribution: hass commentedThere are bugs in translateable strings and D8 first.
Comment #4
ndewhurstOK, thanks. I'll try to get my D8 install up to speed and take a stab at this when I get a chance. What are the translatable string bugs (just so I know where to look)? I can reformat the t() calls to not use a multi-line string argument.
PS - for doing D8 work, should I create a separate issue, or stay within this one and update the issue version accordingly?
Comment #5
hass CreditAttribution: hass commentedMultiline is not supported by potx extractor. No need for a extra D8 case.
Comment #5.0
hass CreditAttribution: hass commentedUpdated issue summary.
Comment #6
hass CreditAttribution: hass commentedFixed the bugs, added uninstall, added tests, corrected logic.
But I guess that the code in googleanalytics.js causes double trackings and collide with the rest of the tracking in these file. I have not tested this feature myself.
Comment #8
hass CreditAttribution: hass commentedFixed one variable name.
Comment #9
hass CreditAttribution: hass commentedSuxxx EGit.
Comment #10
hass CreditAttribution: hass commentedComment #13
hass CreditAttribution: hass commented