Hi,
I would like to understand if Munchkin can track page tags? I want to put two standard tags on all the pages, say Tag_Product and Tag_Solution, would like to add leads to appropriate lists based on their page visit history. Example, if a leads visits a page with Tag_Product = "Network", i would add them to network list, or they visit a page tagged with Tag_Product = "Sever" I will add them to server list.
Is there any out of box, or any other recommended solution/alternatives?
Thanks for reading and your help! I will be compiling and sharing the answers for the benefit of the forum.
Deepak
Solved! Go to Solution.
I mean literally all the JS I posted goes inside
success: function(){
}
Honestly the fact that you're loading Munchkin asynchronously is making it harder for you to customize the code because you're not a JS guy. You'd be better off using the regular embed code and putting it at the bottom of your HTML. I'm not always a fan of loading Munchkin.js async because the very thing that makes async attractive -- doesn't interfere with other assets or page rendering/navigation -- is also leaving room for Munchkin to fail to register a page view before the user navigates away from the page. Of course in most cases it's beneficial, but in specific edge cases you might lose a log entry because the page has been told not to wait for Munchkin.js before moving on.
Deepak, perhaps you should submit an Idea to add a page's meta tags to the Visits Web Page activity as well as including those as a Constraint on the Visited Web Page filter and Visits Web Page trigger. That would be the best way to handle this as an out-of-the-box function in Marketo.
Even better/in addition, if there were an official way (rather than a hack) to customize the first Visit Web Page from Munchkin::init, then we could code up whatever we want.
Hi Deepak,
I'm assuming by tags, you mean parameters at the end of your URL? Something like http://www.google.com?Tag_Product=Network&Tag_Solution=StuffIn that case, you can simply use a "Visited Web Page" filters with the Querystring constraint (say, contains Tag_Product=Network) and then have a flow step to add them to a static list (or, alternately, just make a smart list that does it all in one go.)
Hi Courtney, thanks for responding. Indeed I want to track the HTML mega tags, that will be put under the HTML code. It will not reflect on the URL.
Deepak
If you need to add data from the document itself before logging Visited Web Page activity, I recommend adding it to the hash before you initialize Munchkin:
var productMeta=document.head.querySelector('META[name="tag_product"]');
if (productMeta) document.location.hash = "tag_product:" + productMeta.getAttribute('content');
Munchkin.init('XXX-YYY-ZZZ');
When you run Munchkin::init() you always get a Visited activity (there are obscure and undocumented ways to turn that off, but let's assume in practice you can't). So while Courtney's suggestion of using Munchkin::visitWebPage will work, it'll always add a second Visited Web Page action. I tend to find that cumbersome if you can avoid it.
Of course if you are using hash-bang navigation or anything like that you'll need to deal with the hash change. Otherwise it'll be transparent and will get the metadata tags into your Marketo db.
Hi Sanford, can you please validate my script, somehow the "website visit" trigger is not firing when I write a condition web page contains "all access workplace"
<script type="text/javascript">
jQuery(function($){
$.ajax({
url: document.location.protocol + '//munchkin.marketo.net/munchkin.js',
dataType: 'script',
cache: true,
var MOKeywords=document.head.querySelector('META[name="keywords"]');
if (MOKeywords) document.location.hash = "MOKeywords:" + MOKeywords.getAttribute('content');
success: function() {
Munchkin.init('XXX-YYY-XXX');
}
});
});
</script>
Way on the top, I have a keyword meta tag defined as:
<meta name="keywords" itemprop="keywords" content="all access workplace,all wireless office,rightsizing,microsoft lync,gigabit wi-fi,wlan,ucc,unified communication,all-wireless" /> |
All your code needs to be in the success: listener (starting with "var..."). I'm sure if you look at your JS console you'll see a syntax error now.
Thanks Sanford. Sorry that I am not a java script guy (already put in an idea to create this as feature).
Is this what you mean
!-- Marketo -->
jQuery(function($){
$.ajax({
url: document.location.protocol + '//munchkin.marketo.net/munchkin.js',
dataType: 'script',
cache: true,
success: listener( {
var MOKeywords=document.head.querySelector('META[name="keywords"]');
if (MOKeywords) document.location.hash = "MOKeywords:" + MOKeywords.getAttribute('content');
});
success: function() {
Munchkin.init('009-RUR-657');
}
});
});
Hi Sanford, after I implemented the script, our web team asked not to modify the URL. Unfortunately i need to take the "append to URL" part down.
I am OK posting duplicate URL if I can qualify the second/duplicate URL. Can you please recommend if a mix of your approach and Courtney's approach would work?
I tried below, it does not seem to be logging the second URL: Please help
<script type="text/javascript"> | ||||
jQuery(function($){ | ||||
$.ajax({ | ||||
url: document.location.protocol + '//munchkin.marketo.net/munchkin.js', | ||||
dataType: 'script', | ||||
cache: true, | ||||
success: function() { | ||||
Munchkin.init('XXX-YYY-ZZZ’); |
var MOKeywords=document.head.querySelector('META[name="keywords"]'); | ||||
if (MOKeywords) Munchkin.munchkinFunction('visitWebPage', { url: '/MO:meta-tag/' + MOKeywords.getAttribute('content') }); | ||||
} | ||||
}); | ||||
}); | ||||
</script> |
I wouldn't use colons in the path part of a URL (even a fake URL). It runs the risk of screwing up parsing. Just /meta-tag/servers seems appropriate.
But you're also losing the real page (document.html) and query string. Why not include that, too?
Where's your test page for this?
Hi Sanford, appears I am doing something fundamentally wrong.
Our production pages are working fine, able to track visit:
http://www.arubanetworks.com/solutions/all-wireless-workplace/
None of the TEST page is logging activity. There are 7 of them.
http://www.arubanetworks.com/mktotest1.html - old tracking code, with URL and keywords. Not working.
http://www.arubanetworks.com/mktotest2.html - New tracking code, as-is copied from admin console. In the body tag. Not working.
http://www.arubanetworks.com/mktotest3.html - New tracking code, as-is from admin console, outside the body tag.
http://www.arubanetworks.com/mktotest4.html - New code, outside body and html tag
http://www.arubanetworks.com/mktotest5.html - new code with modified URL
http://www.arubanetworks.com/mktotest6.html - New code with document url
http://www.arubanetworks.com/mktotest7.html - new code with keyword
Once these are working successfully, I will combine test code 5, 6 and 7 to get correct logging.
Thanks
Deepak
All these errors are are viewable in your browser's console. You really need to get used to opening the console while you work!
mktotest1.html has a syntax error. You used a backtick ` instead of a single quote '.
mktotest2.html - mktotest7.html all fail on "$ is not defined." This is because you did not include the jQuery library on the page, yet you're attempting to use jQuery.ajax().
Thanks Sanford. I learnt to work in console a bit, and that helped. My code is now working.
Deepak
Deepak - I voted for your Idea. I'm sure others will too - hint, hint Sanford
I mean literally all the JS I posted goes inside
success: function(){
}
Honestly the fact that you're loading Munchkin asynchronously is making it harder for you to customize the code because you're not a JS guy. You'd be better off using the regular embed code and putting it at the bottom of your HTML. I'm not always a fan of loading Munchkin.js async because the very thing that makes async attractive -- doesn't interfere with other assets or page rendering/navigation -- is also leaving room for Munchkin to fail to register a page view before the user navigates away from the page. Of course in most cases it's beneficial, but in specific edge cases you might lose a log entry because the page has been told not to wait for Munchkin.js before moving on.
Thank you Sanford, Elliott and Courtney for your support. As a workaround, I could finally add the contents of keywords meta tag into web tracking, and use it as constraints on "Visited Website Filter". Here is the final piece of code. Added two lines highlighted in BOLD.
My page has a meta tag header keywords as defined below:
<meta name="keywords" itemprop="keywords" content="all access workplace,all wireless office,rightsizing,microsoft lync,gigabit wi-fi,wlan,ucc,unified communication,all-wireless" /
Solution that worked for me (recommended by Sanford)
============
<!-- Marketo -->
<script type="text/javascript">
jQuery(function($){
$.ajax({
url: document.location.protocol + '//munchkin.marketo.net/munchkin.js',
dataType: 'script',
cache: true,
success: function() {
var MOKeywords=document.head.querySelector('META[name="keywords"]');
if (MOKeywords) document.location.hash = "MOKeywords:" + MOKeywords.getAttribute('content');
Munchkin.init('XXX-YYY-ZZZ’);
}
});
});
</script>
===========
** Comment from Sanford: Honestly the fact that you're loading Munchkin asynchronously is making it harder for you to customize the code because you're not a JS guy. You'd be better off using the regular embed code and putting it at the bottom of your HTML. I'm not always a fan of loading Munchkin.js async because the very thing that makes async attractive -- doesn't interfere with other assets or page rendering/navigation -- is also leaving room for Munchkin to fail to register a page view before the user navigates away from the page. Of course in most cases it's beneficial, but in specific edge cases you might lose a log entry because the page has been told not to wait for Munchkin.js before moving on
Alternate sultion suggested by Courtney
** This may log two activity records per website visit
One solution you could consider is to do a quick JavaScript call with this using faux URLs; let's say, for instance, you have
<meta name="product" property="text" content="This is a product" />
As a meta tag in the header of your page. You could do something akin to
===============
<script src='http://munchkin.marketo.net/munchkin.js' type='text/javascript'></script>
<script>
Munchkin.init('###-###-###');
var x = document.getElementsByTagName("META");
var txt = "";
var i;
for (i = 0; i < x.length; i++) {
if (x[i].name=="product")
{
Munchkin.munchkinFunction('visitWebPage', { url: '/meta-tag/product'});
}
}
</script>
===========
Where you would have Marketo record a fake URL when someone visits a page with the meta name of product. This code would obviously need to be tweaked to the parameters you're using, but it'll at least generate something in Marketo to generate lists with.
Ahhh, I see now.
In terms of the meta tags, the big issue is going to be if there's any categorical structure that notes something is part of a meta tag; Marketo doesn't really do a good job parsing existing data.
One solution you could consider is to do a quick JavaScript call with this using faux URLs; let's say, for instance, you have
<meta name="product" property="text" content="This is a product" />
As a meta tag in the header of your page. You could do something akin to
<script src='http://munchkin.marketo.net/munchkin.js' type='text/javascript'></script> | |
<script> | |
Munchkin.init('###-###-###'); | |
var x = document.getElementsByTagName("META"); | |
var txt = ""; | |
var i; | |
for (i = 0; i < x.length; i++) { | |
if (x[i].name=="product") | |
{ | |
Munchkin.munchkinFunction('visitWebPage', { url: '/meta-tag/product'}); | |
} | |
} | |
</script> | |
Where you would have Marketo record a fake URL when someone visits a page with the meta name of product. This code would obviously need to be tweaked to the parameters you're using, but it'll at least generate something in Marketo to generate lists with.
Hey Courtney, check this one out: CodePen - Meta to Query String. I was going to post it yesterday but didn't because of browser compat (triggers a reload in IE8 and IE9, magical everywhere else).
Sanford Whiteman the link you provided displays a blank page for me. Is there an alternative link to that content?
Sure, just substitute "pen" for the word "debug" in the URL. There isn't any body HTML on the page itself, though -- it's to demonstrate how the URL magically changes to include the META tag, but without refreshing.