Pushing key/value pairs to GTM data layer from page URL - url

I'm ne to the related platforms but trying to solve for pushing the data in "?key=key&value=value" when appended to a URL into the GTM data layer.
I've read through the conventional guidance, created URL variables in GTM and Data Layer variables linked to these.
The point where I am struggling is that I currently have this:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({'dlkey': 'dvalue'});
As in place to push the variables to the data layer, but in the preview I see I am getting nonsense:
Data layer after preview
I am using a stock website to play around with.
This is what the Variables output looks like:
enter image description here
Based on this query parameter: ?key=animal&value=donkey
would really appreciate a nudge in the right direction

Related

Dynamically generate source data for Mapbox-GL layer

We are currently building an asset tracking widget using Mapbox-GL.
When zoomed in, we show the actual assets, and this works fine.
But, when zooming out, we would like to switch to a cluster view to get a proper overview of how many assets are where.
From my understanding, such layer needs to have a predefined datasource. eg. GeoJson.
Is there any way to feed Mapbox-GL data from live JS data?
The assets themselves are markers, an afaik there is no way to switch from makers to something else.
So I assume we would have to generate the datasource from the data that makes up the markers somehow?
The sources seems to be using URL's for getting the actual data so I'm at loss here,
Can I transform a set of geo points into something that MapboxGL can use as a data source?
It's rather confusing what you are asking, but in general, there is no problem with updating data live.
Create the data source:
map.addSource('assets', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }})
Then update it:
map.getSource('assets').setData({ ... })
I didn't understand what you mean by:
such layer needs to have a predefined datasource. eg. GeoJson.
or
The assets themselves are markers,
or
an afaik there is no way to switch from makers to something else

anyone got mapdeck working with OSGB vector tiles?

Trying to stretch my understanding of how mapdeck can plot maps and the new (new to me) Ordnance Survey Vector Tile API that can display 3D buildings
See
https://labs.os.uk/public/os-data-hub-examples/os-vector-tile-api/vts-example-3d-buildings
Has anyone any advice about how to reference the labs.os.uk data as a layer in mapdeck?
I suspect it is not possible to set a transformRequest function when using Mapbox via Mapdeck.
But you can probably do it by downloading the tile json from https://api.os.uk/maps/vector/v1/vts&key=your_os_api_key&srs=3857
Edit by appending &srs=3857 to the "tiles" url.
Save the edited tile json to your server.
Then download a copy of the 3d style json from https://github.com/OrdnanceSurvey/OS-Vector-Tile-API-Stylesheets/blob/master/OS_VTS_3857_3D.json
Edit by appending &key=your_os_api_key to the "sprite" and "glyphs" urls, and edit the "sources" "url" entry to point the tile json on your server.
Save the edited style json to your server.
Hopefully Mapdeck can then be used with style = parameter set to the url of the style json on your server.

Google Sheet find cell by URL parameter

I have a database of elements, each element has its own QR Code. After reading the code I would like to be able to open the worksheet on a specific tab and jump to the appropriate cell (according to the element name). Calling a worksheet through a URL with the #gid parameter allows you to open a tab.... the "range" parameter allows you to jump to a specific cell.... and what if I want to search for an item by name? Something like: https://docs.google.com/spreadsheets/d/1fER4x1p.../edit#gid=82420100&search=element_name.... is it possible?
Google has not introduced this yet
But you can look into Google Script (Googles SpreadSheets macros like) to achieve this.
Also a simpler approach will be to just filter the data, but this will change your requirement obviously. For example you can create a Filter with the name you are looking for and then you will get the URL.
This is the URL to a Sample of this, it should open the
Spreadsheet and filter the data when loaded. This is the Icon to
look for to create the filters
here is some documentation for you to get started on Google App Script, but I don't have a direct link to let you know how to catch the parameters for it to process them. What I can tell you is that this is a much more complicated approach than just a URL because it involves programmatic processing on the Spreadsheet side.

Set the Visitor ID in Adobe Analytics through DTM

I'm trying to set the Visitor ID in Adobe Analytics through DTM.
Above the s_code I have:
var visitor = new Visitor("xxxx")
visitor.trackingServer = "xxx.xx.xx.omtrdc.net"
I've created a data element where the legacy code used to call the
Visitor.getInstance("xxxx");
and set the Visitor ID to %Visitor ID%
That's not working however, and my visitor ID is always just set to %Visitor ID% and obviously not reading any values. I'd really appreciate any input that someone can give me.
Thanks,
Mike
The Visitor ID pops s.visitorID and is in general related to visitor id, but is not the same as s.visitor which is what gets popped for the VisitorAPI integration. DTM does not currently have a built-in field for the s.visitor variable, so you will have to set it yourself within the config, either in the Library Management code editor (assuming you are opting to c/p the core lib and not the "Managed by Adobe" option) or else in the Custom Page Code section.
Since you are popping it in a data layer first, you can reference the data layer like this:
s.visitor = _satellite.getVar('Visitor ID');
NOTE: A separate potential issue you may have is with whether or not the Visitor object is available for your data element. Since data elements are the first thing to be evaluated by DTM, you will need to ensure that the VisitorAPI.js library is output before your top page DTM script include.
If this is a problem for you, or if you are wanting to host VisitorAPI.js within DTM, then you may need to adjust where you are popping that stuff. For example, place the VisitorAPI core code above the custom code as the first stuff within the data element, before:
var visitor = new Visitor("xxxx") visitor.trackingServer = "xxx.xx.xx.omtrdc.net
Or, don't use the data element at all. Instead, put the VisitorAPI code within the Adobe Analytics custom code or core lib section and pop all that stuff (aboove the s.visitor assignment). Or a number of other methods; point is, VisitorAPI stuff must be loaded before the data element can make use of it, same as it must be loaded before Adobe Analytics can make use of it.
So DTM is changing pretty fast and furious right now. They have a "Marketing Cloud Service ID" that works well. Before I used that, however, I did find a way to fix the code. Crayon Violent was right, as usual, that the problem was that the script wasn't available yet. I fixed this by putting the following code in between the VisitorAPI.js and the AppMeasurement stuff in the DTM managed library.
var aA = new AppMeasurement();
aA.visitorNamespace="companyname";
aA.visitor = Visitor.getInstance("companyname");
In addition, there were also some issues using my localhost for testing while trying to see if I had this correct or not. If you are having issues and think you have it correct, it may be worthwhile to elevate it to a different environment.

How to dynamically generate url for image map in Oracle ApEx?

The scenario:
I have an ApEx page which pulls a record from a table. The record contains an id, the name of the chart (actually a filename) and the code for an image map as an NVARCHAR2 column called image_map.
When I render the page I have an embedded HTML region which pulls the image in using the #WORKSPACE_IMAGES#&P19_IMAGE. substitution as the src for the image.
Each chart has hot spots (defined in the image_map html markup) which point to other charts on the same ApEx page. I need to embed the:
Application ID (like &APP_ID.)
Session (like &APP_SESSION.)
My problem:
When I try to load the &APP_ID as part of the source into the database it pre-parses it and plugs in the value for the ApEx development app (e.g. 4500) instead of the actual target application (118).
Any help would be greatly appreciated.
Not a lot of feedback - guess I'm doing something atypical?
In case someone else is trying to do this, the workaround I ended up using was to have a javascript run and replace some custom replacement flags in the urls. The script is embedded in the template of the page and assigns the APEX magic fields to local variables, e.g.:
var my_app_id = '&APP_ID';
Not pretty, but it works...
Ok - I think I've left this open long enough... In the event that anyone else is trying to (mis)use apex in a similar way, it seems like the "apex way" is to use dynamic actions (which seem stable from 4.1.x) and then you can do your dynamic replace from there rather than embedding js in the page(s) themselves.
This seems to be the most maintainable, so I'll mark this as the answer - but if someone else has a better idea, I'm open to education!
I found it difficult to set a dynamic URL on a link to another page - directly - attempting to include the full URL as an individual link target doesn't work, at least in my simplistic world, I'm not an expert (as AJ said: any wisdom appreciated).
Instead, I set individual components of the url via the link, and a 'Before Header' PL/SQL process on the targeted page to combine the elements into a full url and assign it to the full url page-item:
APEX_UTIL.set_session_state(
'PG_FULL_URL',
'http...'||
v('PG_URL_COMPONENT1')||
v('PG_URL_COMPONENT2')||
'..etc..'
);
...where PG_FULL_URL is an item of Type 'Display Image', 'Based On' 'Image URL stored in Page Item Value'.
This is Apex 5.1 btw, I don't know if some of these options are new in this release.

Resources