Can't access a variable from another variable in Google Tag Manager - google-tag-manager

I am having trouble reading between variables in Google Tag Manager.
I am able to fetch data from the data layer, but when I try to access this data from another variable I get "undefined".
Then I tried setting a variable as a constant
and then reading from this variable
But I can't even read a constant value
Any idea why this might be the case?
I tried pulling data from the data layer which worked. The initial value is filled out.
Then I tried to access this value from another variable using {{Variable Name}}, but this value returns "undefined"

I just ran a quick test to reproduce what you have, and I see both of them working just fine like expected on every event:
you have a problem in your testing somewhere.
Like maybe you're looking at a wrong container? Wrong enviornment? Forgot to save code changes?
Oh! There's one more thing! CJS in GTM (and other TMSes) require CSP to allow unsafe-eval. Because all CJS is executed with eval. Without unsafe-eval, all CJS variables will always return undefined. That's most likely your issue. Ask your devs about it. You can read more about GTM and CSP here.

Related

Mapping reference 'myMappingName' of type 'mappingReference' in database 'myDatabaseName' could not be found. (In ADX)

Upon ingestion, a failure is always reported regarding a missing mapping reference. This mapping reference however never existed, nor is it used anywhere. Ingestion however always goes through fine, and all data is present. Any help is greatly appreciated!
I have looked into the logs to see the full reason, and the cause is that it can't find a certain mapping reference. This reference isn't used anywhere and was never created (to the best of my knowledge). Going through all the ingestion mappings on the cluster didn't give any information as to the reason why.
A bit more info on the log:
"OriginatesFromUpdatePolicy": false,
"ErrorCode": BadRequest_MappingReferenceWasNotFound,
Reason for getting Error:
If we did not provide proper Database(onkdb) & Column Data Then we get an Mapping error shown Below.
Resolution for this issue:
Now I have provided Existing Database name(onkdb2) & Column data, Now I am getting Mapping data Below.
In case anyone wanted to know how we are dealing with the problem, currently we have created a mapping that creates empty rows (thus silencing the error). These rows are not mapped out of the source table, so do not affect the child tables.

Calculation spreadsheet is empty

I'am actually working on the calculation spreadsheet (Cartridge dev_basketinfo, pipeline InspectBasket-Start).
It works well but when I got a specific shipping mode (on weightbased and specific postalcode) it is empty.
Do you know something about it please ?
Thanks
The problem was a method called on the fly which invalidate the basket.
If you see an empty spreadsheet be careful with the invalidation or the ruleset.

Using response data from one scenario to another

With Karate, I'm looking to simulate an end-to-end test structure where I do the following:
Make a GET request to specific data
Store a value as a def variable
Use that information for a separate scenario
This is what I have so far:
Scenario: Search for asset
Given url "https://foo.bar.buzz"
When method get
Then status 200
* def responseItem = $.items[0].id // variable initialized from the response
Scenario: Modify asset found
Given url "https://foo.bar.buzz/" + responseItem
// making request payload
When method put.....
I tried reading the documentation for reusing information, but that seemed to be for more in-depth testing.
Thoughts?
It is highly recommended to model flows like this as one scenario. Please refer to the documentation: https://github.com/intuit/karate#script-structure
Variables set using def in the Background will be re-set before every
Scenario. If you are looking for a way to do something only once per
Feature, take a look at callonce. On the other hand, if you are
expecting a variable in the Background to be modified by one Scenario
so that later ones can see the updated value - that is not how you
should think of them, and you should combine your 'flow' into one
scenario. Keep in mind that you should be able to comment-out a
Scenario or skip some via tags without impacting any others. Note that
the parallel runner will run Scenario-s in parallel, which means they
can run in any order.
That said, maybe the Background or hooks is what you are looking for: https://github.com/intuit/karate#hooks

xProc - Pausing a pipeline and continue it when certain event occurs

I'm fairly new to xProc and xPath, but I've been asked to solve the following problem:
Step 2 receives data via the secondary port from step 1. Step 2 contains a p:for-each, which saves a document into a folder for each element that passes the for-each.
(Part A)
These documents (let's say I receive 6 documents from for-each) lay in the same directory and get filtered by p:directory-list and are eventually stored in one single document, containing the whole path of every document the for-each created. (Part B)
So far, so good.
The problem is that Part A seems to be too slow. Part B already tries to read the data Step A
stores while the directory is still empty. Meaning, I'm having a performance / synchronization problem.
And now comes the question:
Is it possible to let the pipeline wait and to let it continue as soon as a certain event occurs?
That's what I'm imagining:
Step B waits as long as necessary until the directory, which Step A stores the data in, is no longer empty. I read something about
dbxml:breakpoint, but unfortunately I couldn't find more information than the name and
a short description of what it seems to do:
Set a breakpoint, optionally based upon a condition, that will cause pipeline operation to pause at the breakpoint, possibly requiring user intervention to continue and/or issuing a message.
It would be awesome if you know more about it and could give an example of how it's used. It would also help if you know a workaround or another way to solve this problem.
UPDATE:
After searching google for half an eternity, I found SMIL which's timesheets seem to do the trick. Has anyone experience with throwing XML / xProc and SMIL together?
Back towards the end of 2009 I proposed the concept of 'Orchestrating XProc with SMIL' http://broadcast.oreilly.com/2009/09/xproc-and-smil-orchestrating-p.html in a blog post on the O'Reilly Network.
However, I'm not sure that this (XProc + Time) is the solution to your problem. It's not entirely clear, to me, from you description what's happening. Are you implying that you're trying to write something to disk and then read it in a subsequent step? You need to keep stuff in the pipeline in order to ensure you can connect outputs to subsequent inputs.

How to determine if a profile data member has ever been set?

I've asked this before but I'm resurrecting it because I didn't get a satisfactory response.
I have a profile variable, and when I load it then it is assigned default values. I need to check to see if it has ever been assigned. Typically I'd use an is null comparison but that won't work.
It was suggested I use the FindProfilesByUserName which seems backward. Regardless this method wont work as it only tells me if the user has any profile created but not for the specific member data I'm interested in. (It seems backwards because the whole purpose of the profiles was to make it easy to access the current user profile data. This seems like a bad design unless I'm missing something.)
The last option I can see is assigning bits to every object to see if they were dirtied or set. I don't want to do this unless required though.
Here is the FindProfilesByUserName sample :
ProfileInfoCollection profileInfo = ProfileManager.FindProfilesByUserName(ProfileAuthenticationOption.All, Membership.GetUser().UserName);
if (profileInfo.Count > 0)
{
if (profileInfo[Membership.GetUser().UserName] != null)
One last idea I've had is storing collections because I think I've read they are nullable. In my case I don't really need a collection but that might be the easiest solution. Look forward to suggestions.. I feel like I must be missing something obvious on this matter.
To be clear
this doesn't work (if http.context.profile.mydata != null)
Okay, I'm surprised no one has experienced this problem: makes me think I'm missing something basic. I'm going to add a group and a dirty flag for the group. If anyone can provide another solution I will give credit for the answer. Or a dirtied flag to the object..
Simply set a default value that represents null. e.g. for an int field, set default to -1.
The requirement that you are describing is, in my opinion, an edge case and in any case is easily fulfilled using the strategy described above.
Your assertion that it is an oversight or shortcoming of the profile model is premature, i think.
Good luck.

Resources