Calling an Extension within Jquery Click Handler

Bronze Contributor
Bronze Contributor

Hello,

We have a need to store a hashed email value in our data layer when a user decides to login to our site. What I am trying to do is to create a jquery click extension that fires when a user clicks the "Log In" button. Within this extension I am setting the email address in a data value. I am trying to utilize the Cryptoextension to hash this value before storing. However, the crypto extension only runs on new page loads and I want it to be able to run on the Log In button click while i still have access to the email value. Is it possible to call the crypto extenson within the jquery click handler? Or is there a better way to go about doing this? My other thought was to do this all via a custom javascript extension but I would really like to avoid having to write the SHA256 hashing mechanism when its already available via the crypto extension.

 

Any help would be great. 

 

Thanks! 

Zach Benchley

2 REPLIES 2

Calling an Extension within Jquery Click Handler

Employee Emeritus

Hi @zbenchley 

If you need a custom solution, you can use the Crypto Extension to choose an encryption method to inject into utag without encrypting anything in particular. Do this by leaving the variables empty

Tealium IQ 2019-02-28 13-25-27.png

The Hashing Method encryption code will be added as a new method in the utag.ut object. In this case, as utag.ut.sha256

Then in your Javascript Extension can then use the following to do the encryption on a variable:

b['variable_name'] = utag.ut.sha256.SHA256(b['variable_name']).toString()

 

Hope that helps!

 

Calling an Extension within Jquery Click Handler

Bronze Contributor
Bronze Contributor

Sweet. This was super helpful! Really appreciate it

Public