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

Implement user_id and pass it in marketo submission #14440

Merged
merged 7 commits into from
Oct 31, 2024

Conversation

mtruj013
Copy link
Contributor

@mtruj013 mtruj013 commented Oct 21, 2024

Done

  • Implemented “user_id” feature to send universally unique identifiers to Google Analytics as described here
  • Added functionality to pass value on form submission

QA

Issue / Card

Fixes https://warthogs.atlassian.net/browse/WD-14942

@webteam-app
Copy link

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.64%. Comparing base (6f5e37b) to head (7628818).
Report is 44 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14440      +/-   ##
==========================================
+ Coverage   69.58%   69.64%   +0.05%     
==========================================
  Files         120      120              
  Lines        3419     3419              
  Branches     1178     1174       -4     
==========================================
+ Hits         2379     2381       +2     
+ Misses       1015     1013       -2     
  Partials       25       25              

see 1 file with indirect coverage changes

@mtruj013 mtruj013 marked this pull request as draft October 21, 2024 16:42
@mtruj013 mtruj013 marked this pull request as ready for review October 22, 2024 14:51
@eabashidze
Copy link
Member

Hi team! I could not catch user_id in Marketo after testing. Here are the results:
As the first step, I added the hidden field to marketo enrichment form, and set it as non-mandatory.
On the website end, user_id does not become visible in document.cookies after cookies are accepted, only after I refresh it. Same for dataLayer, user_id becomes visible after accepting cookies + the refresh. When I navigate to the form (submitted 2 contact us forms), it's visible neither in data layer, nor in the payload. I can see user_id in the cookie part of the network tab (checking the submitting activity), but still not passed to mkto. Please advise on next steps.

@mtruj013
Copy link
Contributor Author

Thanks @eabashidze , I've pushed a fix for the cookie only being set after refresh, but I'm still trying to figure out why the id isn't being submitted even though I've added it to the enrichment payload. Will ping you once I have a fix

@eabashidze
Copy link
Member

Hi @mtruj013 @laszlokajtar ,
I confirm that all the issues are solved and test went through.
Thanks!
Screenshot from 2024-10-24 14-01-57
Screenshot from 2024-10-24 13-58-31

@laszlokajtar
Copy link
Contributor

@mtruj013 @eabashidze thanks a lot for figuring it out!

@laszlokajtar
Copy link
Contributor

@mtruj013 @eabashidze i've had multiple sessions now where user_id wasn't generated for me. is this an exception?

@laszlokajtar
Copy link
Contributor

@mtruj013 @eabashidze also, in a new incognito session, while the user_id was in the cookies, it disappears or doesn't get pushed into the dataLayer on page reload for me

If the user has not set their cookie preference, wait for the cookie policy to run first.
*/

import { v4 as uuidv4 } from "https://jspm.dev/uuid";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to install and import uuidv4 npm package instead. This import looks a bit unusual to me. Is it written somewhere that this is the way it should be done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be available client side without a bundler, so I've used a cdn as suggested here

document.cookie.match(new RegExp("(^| )" + targetCookie + "=([^;]+)"));
let cookieAcceptanceValue = getCookie("_cookies_accepted");

if (cookieAcceptanceValue === null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the value is None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of that cookie when not set is null, but updated to catch more falsey values

@mtruj013
Copy link
Contributor Author

@laszlokajtar I fixed the dataLayer not persisting but, I couldn't replicate any session wherein user_id wasn't generated on chrome or ff, incognito or otherwise. Please flag if you're still having this issue. I've tested on multiple pages and checked on marketo and everything seems to be working as expected

@akbarkz akbarkz merged commit af116b9 into canonical:main Oct 31, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants